From 24931fe043b7198459434d6c0475bd36ff535b2b Mon Sep 17 00:00:00 2001 From: Marco Antonio Alvarez Date: Sun, 17 Mar 2024 12:17:51 +0100 Subject: [PATCH] more formatting fixes --- bindings/matrix-sdk-ffi/src/timeline/mod.rs | 58 ++++++++++--------- crates/matrix-sdk-ui/src/timeline/futures.rs | 16 ++--- crates/matrix-sdk-ui/src/timeline/mod.rs | 2 +- crates/matrix-sdk/src/encryption/mod.rs | 5 +- crates/matrix-sdk/src/media.rs | 6 +- crates/matrix-sdk/src/room/futures.rs | 46 +++++++-------- crates/matrix-sdk/src/room/mod.rs | 8 +-- .../tests/integration/room/joined.rs | 14 ++--- 8 files changed, 80 insertions(+), 75 deletions(-) diff --git a/bindings/matrix-sdk-ffi/src/timeline/mod.rs b/bindings/matrix-sdk-ffi/src/timeline/mod.rs index 2394ca70758..d9927aec58b 100644 --- a/bindings/matrix-sdk-ffi/src/timeline/mod.rs +++ b/bindings/matrix-sdk-ffi/src/timeline/mod.rs @@ -58,7 +58,7 @@ use crate::{ error::{ClientError, RoomError}, helpers::unwrap_or_clone_arc, ruma::{ - AssetType, AudioInfo, FileInfo, FormattedBody, ImageInfo, PollKind, ThumbnailInfo, + AssetType, AudioInfo, FileInfo, FormattedBody, ImageInfo, PollKind, ThumbnailInfo, VideoInfo, }, task_handle::TaskHandle, @@ -119,7 +119,7 @@ impl Timeline { Some(p) => Some(RumaFormattedBody::from(p)), None => None, }; - let request = + let request = self.inner.send_attachment(url, mime_type, attachment_config, caption, formatted); if let Some(progress_watcher) = progress_watcher { let mut subscriber = request.subscribe_to_send_progress(); @@ -252,13 +252,14 @@ impl Timeline { }; self.send_attachment( - url, - mime_type, - attachment_config, + url, + mime_type, + attachment_config, caption, - formatted, - progress_watcher - ).await + formatted, + progress_watcher, + ) + .await })) } @@ -292,13 +293,14 @@ impl Timeline { }; self.send_attachment( - url, - mime_type, - attachment_config, - caption, + url, + mime_type, + attachment_config, + caption, formatted, - progress_watcher - ).await + progress_watcher, + ) + .await })) } @@ -323,13 +325,14 @@ impl Timeline { let attachment_config = AttachmentConfig::new().info(attachment_info); self.send_attachment( - url, - mime_type, - attachment_config, - caption, - formatted, - progress_watcher - ).await + url, + mime_type, + attachment_config, + caption, + formatted, + progress_watcher, + ) + .await })) } @@ -357,12 +360,13 @@ impl Timeline { self.send_attachment( url, - mime_type, - attachment_config, - caption, - formatted, - progress_watcher - ).await + mime_type, + attachment_config, + caption, + formatted, + progress_watcher, + ) + .await })) } diff --git a/crates/matrix-sdk-ui/src/timeline/futures.rs b/crates/matrix-sdk-ui/src/timeline/futures.rs index 6e0e915a99f..d5ef74ef971 100644 --- a/crates/matrix-sdk-ui/src/timeline/futures.rs +++ b/crates/matrix-sdk-ui/src/timeline/futures.rs @@ -55,14 +55,14 @@ impl<'a> IntoFuture for SendAttachment<'a> { fn into_future(self) -> Self::IntoFuture { let Self { - timeline, - url, - mime_type, - config, - caption, - formatted, - tracing_span, - send_progress + timeline, + url, + mime_type, + config, + caption, + formatted, + tracing_span, + send_progress, } = self; let fut = async move { let urlbody = Path::new(&url) diff --git a/crates/matrix-sdk-ui/src/timeline/mod.rs b/crates/matrix-sdk-ui/src/timeline/mod.rs index 57973336515..c23d0ba31a9 100644 --- a/crates/matrix-sdk-ui/src/timeline/mod.rs +++ b/crates/matrix-sdk-ui/src/timeline/mod.rs @@ -520,7 +520,7 @@ impl Timeline { /// /// * `config` - An attachment configuration object containing details about /// the attachment - /// + /// /// * `caption` - An optional caption of this attachment /// /// * `formatted` - An optional formatted caption of this attachment diff --git a/crates/matrix-sdk/src/encryption/mod.rs b/crates/matrix-sdk/src/encryption/mod.rs index 191ba113857..1efee6756ff 100644 --- a/crates/matrix-sdk/src/encryption/mod.rs +++ b/crates/matrix-sdk/src/encryption/mod.rs @@ -49,7 +49,7 @@ use ruma::{ assign, events::room::{ message::{ - AudioMessageEventContent, FileInfo, FileMessageEventContent, FormattedBody, + AudioMessageEventContent, FileInfo, FileMessageEventContent, FormattedBody, ImageMessageEventContent, MessageType, VideoInfo, VideoMessageEventContent, }, ImageInfo, MediaSource, ThumbnailInfo, @@ -329,7 +329,7 @@ impl Client { Some(caption) => (caption, Some(url)), None => (url, None), }; - + Ok(match content_type.type_() { mime::IMAGE => { let info = assign!(info.map(ImageInfo::from).unwrap_or_default(), { @@ -1447,6 +1447,7 @@ impl Encryption { #[cfg(all(test, not(target_arch = "wasm32")))] mod tests { use std::time::Duration; + use matrix_sdk_base::SessionMeta; use matrix_sdk_test::{ async_test, test_json, GlobalAccountDataTestEvent, JoinedRoomBuilder, StateTestEvent, diff --git a/crates/matrix-sdk/src/media.rs b/crates/matrix-sdk/src/media.rs index 3cd0bfe4b02..d07246fb3f7 100644 --- a/crates/matrix-sdk/src/media.rs +++ b/crates/matrix-sdk/src/media.rs @@ -30,8 +30,8 @@ use ruma::{ assign, events::room::{ message::{ - self, AudioInfo, AudioMessageEventContent, FileInfo, FileMessageEventContent, - FormattedBody, ImageMessageEventContent, MessageType, UnstableAudioDetailsContentBlock, + self, AudioInfo, AudioMessageEventContent, FileInfo, FileMessageEventContent, + FormattedBody, ImageMessageEventContent, MessageType, UnstableAudioDetailsContentBlock, UnstableVoiceContentBlock, VideoInfo, VideoMessageEventContent, }, ImageInfo, MediaSource, ThumbnailInfo, @@ -463,7 +463,7 @@ impl Media { try_join(upload_thumbnail, upload_attachment).await?; let url = url.to_owned(); - let (body, filename)= match caption { + let (body, filename) = match caption { Some(caption) => (caption, Some(url)), None => (url, None), }; diff --git a/crates/matrix-sdk/src/room/futures.rs b/crates/matrix-sdk/src/room/futures.rs index e015991c104..2527be139b2 100644 --- a/crates/matrix-sdk/src/room/futures.rs +++ b/crates/matrix-sdk/src/room/futures.rs @@ -267,26 +267,26 @@ impl<'a> IntoFuture for SendAttachment<'a> { fn into_future(self) -> Self::IntoFuture { let Self { - room, - url, - content_type, - data, - config, - caption, - formatted, - tracing_span, - send_progress + room, + url, + content_type, + data, + config, + caption, + formatted, + tracing_span, + send_progress, } = self; let fut = async move { if config.thumbnail.is_some() { room.prepare_and_send_attachment( - url, - content_type, - data, - config, - caption, - formatted, - send_progress + url, + content_type, + data, + config, + caption, + formatted, + send_progress, ).await } else { #[cfg(not(feature = "image-proc"))] @@ -346,13 +346,13 @@ impl<'a> IntoFuture for SendAttachment<'a> { }; room.prepare_and_send_attachment( - url, - content_type, - data, - config, - caption, - formatted, - send_progress + url, + content_type, + data, + config, + caption, + formatted, + send_progress, ).await } }; diff --git a/crates/matrix-sdk/src/room/mod.rs b/crates/matrix-sdk/src/room/mod.rs index a1c73635897..1e01ab55b5d 100644 --- a/crates/matrix-sdk/src/room/mod.rs +++ b/crates/matrix-sdk/src/room/mod.rs @@ -1421,7 +1421,7 @@ impl Room { #[instrument(skip_all)] pub async fn enable_encryption(&self) -> Result<()> { use ruma::{ - events::room::encryption::RoomEncryptionEventContent, EventEncryptionAlgorithm, + events::room::encryption::RoomEncryptionEventContent, EventEncryptionAlgorithm, }; const SYNC_WAIT_TIME: Duration = Duration::from_secs(3); @@ -1705,7 +1705,7 @@ impl Room { /// * `caption` - An optional caption of the media that is going to be /// uploaded. /// - /// * `formatted` - A optional formatted caption of the media that is going + /// * `formatted` - A optional formatted caption of the media that is going /// to be uploaded. /// /// # Examples @@ -1770,7 +1770,7 @@ impl Room { /// media. /// /// * `config` - Metadata and configuration for the attachment. - /// + /// /// * `caption` - An optional caption of the media that is going to be /// uploaded. /// @@ -2871,7 +2871,7 @@ pub struct TryFromReportedContentScoreError(()); mod tests { use matrix_sdk_base::SessionMeta; use matrix_sdk_test::{ - async_test, test_json, JoinedRoomBuilder, StateTestEvent, SyncResponseBuilder, + async_test, test_json, JoinedRoomBuilder, StateTestEvent, SyncResponseBuilder, }; use ruma::{device_id, int, user_id}; use wiremock::{ diff --git a/crates/matrix-sdk/tests/integration/room/joined.rs b/crates/matrix-sdk/tests/integration/room/joined.rs index 9a9256955e7..7207b36cd6b 100644 --- a/crates/matrix-sdk/tests/integration/room/joined.rs +++ b/crates/matrix-sdk/tests/integration/room/joined.rs @@ -482,12 +482,12 @@ async fn room_attachment_send_wrong_info() { let response = room .send_attachment( - "image.jpg", - &mime::IMAGE_JPEG, - b"Hello world".to_vec(), - config, - Some("image caption".to_string()), - None + "image.jpg", + &mime::IMAGE_JPEG, + b"Hello world".to_vec(), + config, + Some("image caption".to_string()), + None, ).await; response.unwrap_err(); @@ -555,7 +555,7 @@ async fn room_attachment_send_info_thumbnail() { })); let response = room - .send_attachment("image", &mime::IMAGE_JPEG, b"Hello world".to_vec(), config, None, None, ) + .send_attachment("image", &mime::IMAGE_JPEG, b"Hello world".to_vec(), config, None, None) .await .unwrap();