@@ -143,7 +143,7 @@ pub trait MediaEventContent {
143
143
fn source ( & self ) -> Option < MediaSource > ;
144
144
145
145
/// Get the name of the uploaded file for `Self`.
146
- fn filename ( & self ) -> Option < String > ;
146
+ fn filename_or_body ( & self ) -> Option < String > ;
147
147
148
148
/// Get the source of the thumbnail for `Self`.
149
149
///
@@ -156,7 +156,7 @@ impl MediaEventContent for StickerEventContent {
156
156
Some ( MediaSource :: from ( self . source . clone ( ) ) )
157
157
}
158
158
159
- fn filename ( & self ) -> Option < String > {
159
+ fn filename_or_body ( & self ) -> Option < String > {
160
160
None
161
161
}
162
162
@@ -170,8 +170,8 @@ impl MediaEventContent for AudioMessageEventContent {
170
170
Some ( self . source . clone ( ) )
171
171
}
172
172
173
- fn filename ( & self ) -> Option < String > {
174
- self . filename . clone ( )
173
+ fn filename_or_body ( & self ) -> Option < String > {
174
+ Some ( self . filename . clone ( ) . unwrap_or_else ( || self . body . clone ( ) ) )
175
175
}
176
176
177
177
fn thumbnail_source ( & self ) -> Option < MediaSource > {
@@ -184,8 +184,8 @@ impl MediaEventContent for FileMessageEventContent {
184
184
Some ( self . source . clone ( ) )
185
185
}
186
186
187
- fn filename ( & self ) -> Option < String > {
188
- self . filename . clone ( )
187
+ fn filename_or_body ( & self ) -> Option < String > {
188
+ Some ( self . filename . clone ( ) . unwrap_or_else ( || self . body . clone ( ) ) )
189
189
}
190
190
191
191
fn thumbnail_source ( & self ) -> Option < MediaSource > {
@@ -198,7 +198,7 @@ impl MediaEventContent for ImageMessageEventContent {
198
198
Some ( self . source . clone ( ) )
199
199
}
200
200
201
- fn filename ( & self ) -> Option < String > {
201
+ fn filename_or_body ( & self ) -> Option < String > {
202
202
self . filename . clone ( )
203
203
}
204
204
@@ -215,8 +215,8 @@ impl MediaEventContent for VideoMessageEventContent {
215
215
Some ( self . source . clone ( ) )
216
216
}
217
217
218
- fn filename ( & self ) -> Option < String > {
219
- self . filename . clone ( )
218
+ fn filename_or_body ( & self ) -> Option < String > {
219
+ Some ( self . filename . clone ( ) . unwrap_or_else ( || self . body . clone ( ) ) )
220
220
}
221
221
222
222
fn thumbnail_source ( & self ) -> Option < MediaSource > {
@@ -232,7 +232,7 @@ impl MediaEventContent for LocationMessageEventContent {
232
232
None
233
233
}
234
234
235
- fn filename ( & self ) -> Option < String > {
235
+ fn filename_or_body ( & self ) -> Option < String > {
236
236
None
237
237
}
238
238
0 commit comments