From 4da13e10964d0565d16ea220a271ae451b995a16 Mon Sep 17 00:00:00 2001 From: Benjamin Bouvier Date: Wed, 13 Aug 2025 09:49:06 +0200 Subject: [PATCH] refactor!(ffi): use the send queue by default to upload medias We do consider it stable now, after months of running it in production, so let's use it by default to simplify the `UploadParameters`. --- bindings/matrix-sdk-ffi/CHANGELOG.md | 4 ++++ bindings/matrix-sdk-ffi/src/timeline/mod.rs | 20 +++++++------------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/bindings/matrix-sdk-ffi/CHANGELOG.md b/bindings/matrix-sdk-ffi/CHANGELOG.md index 7bb6b5175..e62c9b83c 100644 --- a/bindings/matrix-sdk-ffi/CHANGELOG.md +++ b/bindings/matrix-sdk-ffi/CHANGELOG.md @@ -36,6 +36,10 @@ All notable changes to this project will be documented in this file. ### Breaking changes: +- The timeline will now always use the send queue to upload medias, so the + `UploadParameters::use_send_queue` bool has been removed. Make sure to listen to the send queue's + error updates, and to handle send queue restarts. + ([#5525](https://github.com/matrix-org/matrix-rust-sdk/pull/5525)) - Support for the legacy media upload progress has been disabled. Media upload progress is available through the send queue, and can be enabled thanks to `Client::enable_send_queue_upload_progress()`. diff --git a/bindings/matrix-sdk-ffi/src/timeline/mod.rs b/bindings/matrix-sdk-ffi/src/timeline/mod.rs index 247ddceca..9ad560f36 100644 --- a/bindings/matrix-sdk-ffi/src/timeline/mod.rs +++ b/bindings/matrix-sdk-ffi/src/timeline/mod.rs @@ -101,8 +101,10 @@ impl Timeline { thumbnail: Option, ) -> Result, RoomError> { let mime_str = mime_type.as_ref().ok_or(RoomError::InvalidAttachmentMimeType)?; + let mime_type = mime_str.parse::().map_err(|_| RoomError::InvalidAttachmentMimeType)?; + let in_reply_to_event_id = params .in_reply_to .map(EventId::parse) @@ -125,15 +127,11 @@ impl Timeline { }; let handle = SendAttachmentJoinHandle::new(get_runtime_handle().spawn(async move { - let mut request = - self.inner.send_attachment(params.source, mime_type, attachment_config); - - if params.use_send_queue { - request = request.use_send_queue(); - } - - request.await.map_err(|_| RoomError::FailedSendingAttachment)?; - Ok(()) + self.inner + .send_attachment(params.source, mime_type, attachment_config) + .use_send_queue() + .await + .map_err(|_| RoomError::FailedSendingAttachment) })); Ok(handle) @@ -197,10 +195,6 @@ pub struct UploadParameters { mentions: Option, /// Optional Event ID to reply to. in_reply_to: Option, - /// Should the media be sent with the send queue, or synchronously? - /// - /// Watching progress only works with the synchronous method, at the moment. - use_send_queue: bool, } /// A source for uploading a file