mirror of
https://github.com/matrix-org/matrix-rust-sdk.git
synced 2026-06-17 04:38:25 -04:00
refactor: Rename fn MediaEventContent::filename to MediaEventContent::filename_or_body since it was previously clashing with another function definition.
Also, make sure it returns either the filename or the body if that's missing - which should contain the actual filename in that case.
This commit is contained in:
@@ -143,7 +143,7 @@ pub trait MediaEventContent {
|
||||
fn source(&self) -> Option<MediaSource>;
|
||||
|
||||
/// Get the name of the uploaded file for `Self`.
|
||||
fn filename(&self) -> Option<String>;
|
||||
fn filename_or_body(&self) -> Option<String>;
|
||||
|
||||
/// Get the source of the thumbnail for `Self`.
|
||||
///
|
||||
@@ -156,7 +156,7 @@ impl MediaEventContent for StickerEventContent {
|
||||
Some(MediaSource::from(self.source.clone()))
|
||||
}
|
||||
|
||||
fn filename(&self) -> Option<String> {
|
||||
fn filename_or_body(&self) -> Option<String> {
|
||||
None
|
||||
}
|
||||
|
||||
@@ -170,8 +170,8 @@ impl MediaEventContent for AudioMessageEventContent {
|
||||
Some(self.source.clone())
|
||||
}
|
||||
|
||||
fn filename(&self) -> Option<String> {
|
||||
self.filename.clone()
|
||||
fn filename_or_body(&self) -> Option<String> {
|
||||
Some(self.filename.clone().unwrap_or_else(|| self.body.clone()))
|
||||
}
|
||||
|
||||
fn thumbnail_source(&self) -> Option<MediaSource> {
|
||||
@@ -184,8 +184,8 @@ impl MediaEventContent for FileMessageEventContent {
|
||||
Some(self.source.clone())
|
||||
}
|
||||
|
||||
fn filename(&self) -> Option<String> {
|
||||
self.filename.clone()
|
||||
fn filename_or_body(&self) -> Option<String> {
|
||||
Some(self.filename.clone().unwrap_or_else(|| self.body.clone()))
|
||||
}
|
||||
|
||||
fn thumbnail_source(&self) -> Option<MediaSource> {
|
||||
@@ -198,7 +198,7 @@ impl MediaEventContent for ImageMessageEventContent {
|
||||
Some(self.source.clone())
|
||||
}
|
||||
|
||||
fn filename(&self) -> Option<String> {
|
||||
fn filename_or_body(&self) -> Option<String> {
|
||||
self.filename.clone()
|
||||
}
|
||||
|
||||
@@ -215,8 +215,8 @@ impl MediaEventContent for VideoMessageEventContent {
|
||||
Some(self.source.clone())
|
||||
}
|
||||
|
||||
fn filename(&self) -> Option<String> {
|
||||
self.filename.clone()
|
||||
fn filename_or_body(&self) -> Option<String> {
|
||||
Some(self.filename.clone().unwrap_or_else(|| self.body.clone()))
|
||||
}
|
||||
|
||||
fn thumbnail_source(&self) -> Option<MediaSource> {
|
||||
@@ -232,7 +232,7 @@ impl MediaEventContent for LocationMessageEventContent {
|
||||
None
|
||||
}
|
||||
|
||||
fn filename(&self) -> Option<String> {
|
||||
fn filename_or_body(&self) -> Option<String> {
|
||||
None
|
||||
}
|
||||
|
||||
|
||||
@@ -169,7 +169,7 @@ use ruma::{
|
||||
};
|
||||
use tokio::sync::{broadcast, oneshot, Mutex, Notify, OwnedMutexGuard};
|
||||
use tracing::{debug, error, info, instrument, trace, warn};
|
||||
|
||||
use matrix_sdk_base::media::MediaEventContent;
|
||||
#[cfg(feature = "e2e-encryption")]
|
||||
use crate::crypto::{OlmError, SessionRecipientCollectionError};
|
||||
use crate::{
|
||||
@@ -1284,10 +1284,10 @@ impl QueueStorage {
|
||||
let store = client.state_store();
|
||||
|
||||
let mut filename = match &event.msgtype {
|
||||
MessageType::Image(msgtype) => msgtype.filename.clone(),
|
||||
MessageType::Audio(msgtype) => msgtype.filename.clone(),
|
||||
MessageType::Video(msgtype) => msgtype.filename.clone(),
|
||||
MessageType::File(msgtype) => msgtype.filename.clone(),
|
||||
MessageType::Image(msgtype) => msgtype.filename_or_body(),
|
||||
MessageType::Audio(msgtype) => msgtype.filename_or_body(),
|
||||
MessageType::Video(msgtype) => msgtype.filename_or_body(),
|
||||
MessageType::File(msgtype) => msgtype.filename_or_body(),
|
||||
_ => None,
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user