Skip to content

Commit

Permalink
ffi: Add caption to audio, file, image and video timeline items.
Browse files Browse the repository at this point in the history
  • Loading branch information
pixlwave committed Oct 7, 2024
1 parent 26a8a17 commit 07b0dde
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions bindings/matrix-sdk-ffi/src/ruma.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,31 +277,31 @@ impl TryFrom<MessageType> for RumaMessageType {
RumaImageMessageEventContent::new(content.body, (*content.source).clone())
.info(content.info.map(Into::into).map(Box::new));
event_content.formatted = content.formatted.map(Into::into);
event_content.filename = content.filename;
event_content.filename = Some(content.filename);
Self::Image(event_content)
}
MessageType::Audio { content } => {
let mut event_content =
RumaAudioMessageEventContent::new(content.body, (*content.source).clone())
.info(content.info.map(Into::into).map(Box::new));
event_content.formatted = content.formatted.map(Into::into);
event_content.filename = content.filename;
event_content.filename = Some(content.filename);
Self::Audio(event_content)
}
MessageType::Video { content } => {
let mut event_content =
RumaVideoMessageEventContent::new(content.body, (*content.source).clone())
.info(content.info.map(Into::into).map(Box::new));
event_content.formatted = content.formatted.map(Into::into);
event_content.filename = content.filename;
event_content.filename = Some(content.filename);
Self::Video(event_content)
}
MessageType::File { content } => {
let mut event_content =
RumaFileMessageEventContent::new(content.body, (*content.source).clone())
.info(content.info.map(Into::into).map(Box::new));
event_content.formatted = content.formatted.map(Into::into);
event_content.filename = content.filename;
event_content.filename = Some(content.filename);
Self::File(event_content)
}
MessageType::Notice { content } => {
Expand Down Expand Up @@ -337,7 +337,8 @@ impl From<RumaMessageType> for MessageType {
content: ImageMessageContent {
body: c.body.clone(),
formatted: c.formatted.as_ref().map(Into::into),
filename: c.filename.clone(),
filename: c.filename().to_owned(),
caption: c.caption().map(ToString::to_string),
source: Arc::new(c.source.clone()),
info: c.info.as_deref().map(Into::into),
},
Expand All @@ -346,7 +347,8 @@ impl From<RumaMessageType> for MessageType {
content: AudioMessageContent {
body: c.body.clone(),
formatted: c.formatted.as_ref().map(Into::into),
filename: c.filename.clone(),
filename: c.filename().to_owned(),
caption: c.caption().map(ToString::to_string),
source: Arc::new(c.source.clone()),
info: c.info.as_deref().map(Into::into),
audio: c.audio.map(Into::into),
Expand All @@ -357,7 +359,8 @@ impl From<RumaMessageType> for MessageType {
content: VideoMessageContent {
body: c.body.clone(),
formatted: c.formatted.as_ref().map(Into::into),
filename: c.filename.clone(),
filename: c.filename().to_owned(),
caption: c.caption().map(ToString::to_string),
source: Arc::new(c.source.clone()),
info: c.info.as_deref().map(Into::into),
},
Expand All @@ -366,7 +369,8 @@ impl From<RumaMessageType> for MessageType {
content: FileMessageContent {
body: c.body.clone(),
formatted: c.formatted.as_ref().map(Into::into),
filename: c.filename.clone(),
filename: c.filename().to_owned(),
caption: c.caption().map(ToString::to_string),
source: Arc::new(c.source.clone()),
info: c.info.as_deref().map(Into::into),
},
Expand Down Expand Up @@ -442,7 +446,8 @@ pub struct EmoteMessageContent {
pub struct ImageMessageContent {
pub body: String,
pub formatted: Option<FormattedBody>,
pub filename: Option<String>,
pub filename: String,
pub caption: Option<String>,
pub source: Arc<MediaSource>,
pub info: Option<ImageInfo>,
}
Expand All @@ -451,7 +456,8 @@ pub struct ImageMessageContent {
pub struct AudioMessageContent {
pub body: String,
pub formatted: Option<FormattedBody>,
pub filename: Option<String>,
pub filename: String,
pub caption: Option<String>,
pub source: Arc<MediaSource>,
pub info: Option<AudioInfo>,
pub audio: Option<UnstableAudioDetailsContent>,
Expand All @@ -462,7 +468,8 @@ pub struct AudioMessageContent {
pub struct VideoMessageContent {
pub body: String,
pub formatted: Option<FormattedBody>,
pub filename: Option<String>,
pub filename: String,
pub caption: Option<String>,
pub source: Arc<MediaSource>,
pub info: Option<VideoInfo>,
}
Expand All @@ -471,7 +478,8 @@ pub struct VideoMessageContent {
pub struct FileMessageContent {
pub body: String,
pub formatted: Option<FormattedBody>,
pub filename: Option<String>,
pub filename: String,
pub caption: Option<String>,
pub source: Arc<MediaSource>,
pub info: Option<FileInfo>,
}
Expand Down

0 comments on commit 07b0dde

Please sign in to comment.