Skip to content

Commit

Permalink
feat(timeline): allow sending mentions along with media
Browse files Browse the repository at this point in the history
Since 8205da8 it has been possible to
attach (intentional) mentions to _edited_ media captions, but the
send_$mediatype() timeline APIs provided no way to send them with the
initial event. This fixes that.

Signed-off-by: Joe Groocock <me@frebib.net>
  • Loading branch information
frebib committed Jan 8, 2025
1 parent 2ef14de commit 595e8a4
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions bindings/matrix-sdk-ffi/src/timeline/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ impl Timeline {
image_info: ImageInfo,
caption: Option<String>,
formatted_caption: Option<FormattedBody>,
mentions: Option<Mentions>,
progress_watcher: Option<Box<dyn ProgressWatcher>>,
use_send_queue: bool,
) -> Arc<SendAttachmentJoinHandle> {
Expand All @@ -313,7 +314,8 @@ impl Timeline {
.thumbnail(thumbnail)
.info(attachment_info)
.caption(caption)
.formatted_caption(formatted_caption);
.formatted_caption(formatted_caption)
.mentions(mentions.map(Into::into));

self.send_attachment(
url,
Expand All @@ -334,6 +336,7 @@ impl Timeline {
video_info: VideoInfo,
caption: Option<String>,
formatted_caption: Option<FormattedBody>,
mentions: Option<Mentions>,
progress_watcher: Option<Box<dyn ProgressWatcher>>,
use_send_queue: bool,
) -> Arc<SendAttachmentJoinHandle> {
Expand All @@ -349,7 +352,8 @@ impl Timeline {
.thumbnail(thumbnail)
.info(attachment_info)
.caption(caption)
.formatted_caption(formatted_caption.map(Into::into));
.formatted_caption(formatted_caption.map(Into::into))
.mentions(mentions.map(Into::into));

self.send_attachment(
url,
Expand All @@ -362,12 +366,14 @@ impl Timeline {
}))
}

#[allow(clippy::too_many_arguments)]
pub fn send_audio(
self: Arc<Self>,
url: String,
audio_info: AudioInfo,
caption: Option<String>,
formatted_caption: Option<FormattedBody>,
mentions: Option<Mentions>,
progress_watcher: Option<Box<dyn ProgressWatcher>>,
use_send_queue: bool,
) -> Arc<SendAttachmentJoinHandle> {
Expand All @@ -381,7 +387,8 @@ impl Timeline {
let attachment_config = AttachmentConfig::new()
.info(attachment_info)
.caption(caption)
.formatted_caption(formatted_caption.map(Into::into));
.formatted_caption(formatted_caption.map(Into::into))
.mentions(mentions.map(Into::into));

self.send_attachment(
url,
Expand All @@ -401,6 +408,7 @@ impl Timeline {
audio_info: AudioInfo,
waveform: Vec<u16>,
caption: Option<String>,
mentions: Option<Mentions>,
formatted_caption: Option<FormattedBody>,
progress_watcher: Option<Box<dyn ProgressWatcher>>,
use_send_queue: bool,
Expand All @@ -416,7 +424,8 @@ impl Timeline {
let attachment_config = AttachmentConfig::new()
.info(attachment_info)
.caption(caption)
.formatted_caption(formatted_caption.map(Into::into));
.formatted_caption(formatted_caption.map(Into::into))
.mentions(mentions.map(Into::into));

self.send_attachment(
url,
Expand All @@ -429,12 +438,14 @@ impl Timeline {
}))
}

#[allow(clippy::too_many_arguments)]
pub fn send_file(
self: Arc<Self>,
url: String,
file_info: FileInfo,
caption: Option<String>,
formatted_caption: Option<FormattedBody>,
mentions: Option<Mentions>,
progress_watcher: Option<Box<dyn ProgressWatcher>>,
use_send_queue: bool,
) -> Arc<SendAttachmentJoinHandle> {
Expand All @@ -448,7 +459,8 @@ impl Timeline {
let attachment_config = AttachmentConfig::new()
.info(attachment_info)
.caption(caption)
.formatted_caption(formatted_caption.map(Into::into));
.formatted_caption(formatted_caption.map(Into::into))
.mentions(mentions.map(Into::into));

self.send_attachment(
url,
Expand Down

0 comments on commit 595e8a4

Please sign in to comment.