From 1609a73e99ea718ca07abce635deff1ca3ebe62e Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Mon, 30 Oct 2023 17:45:11 +0100 Subject: [PATCH] sdk: Update argument order for send_raw --- crates/matrix-sdk/src/encryption/mod.rs | 2 +- crates/matrix-sdk/src/room/futures.rs | 2 +- crates/matrix-sdk/src/room/mod.rs | 12 ++++-------- crates/matrix-sdk/src/widget/matrix.rs | 2 +- 4 files changed, 7 insertions(+), 11 deletions(-) diff --git a/crates/matrix-sdk/src/encryption/mod.rs b/crates/matrix-sdk/src/encryption/mod.rs index b9ce737b9..af5f57f21 100644 --- a/crates/matrix-sdk/src/encryption/mod.rs +++ b/crates/matrix-sdk/src/encryption/mod.rs @@ -1240,7 +1240,7 @@ mod tests { let reaction = ReactionEventContent::new(Annotation::new(event_id.into(), "🐈".to_owned())); room.send(reaction).await.expect("Sending the reaction should not fail"); - room.send_raw(json!({}), "m.reaction").await.expect("Sending the reaction should not fail"); + room.send_raw("m.reaction", json!({})).await.expect("Sending the reaction should not fail"); } #[async_test] diff --git a/crates/matrix-sdk/src/room/futures.rs b/crates/matrix-sdk/src/room/futures.rs index c587f67c9..1ec251fcf 100644 --- a/crates/matrix-sdk/src/room/futures.rs +++ b/crates/matrix-sdk/src/room/futures.rs @@ -86,7 +86,7 @@ impl<'a> IntoFuture for SendMessageLikeEvent<'a> { let Self { room, event_type, content, transaction_id } = self; Box::pin(async move { let content = content?; - assign!(room.send_raw(content, &event_type), { transaction_id }).await + assign!(room.send_raw(&event_type, content), { transaction_id }).await }) } } diff --git a/crates/matrix-sdk/src/room/mod.rs b/crates/matrix-sdk/src/room/mod.rs index f03c66db8..676298ba1 100644 --- a/crates/matrix-sdk/src/room/mod.rs +++ b/crates/matrix-sdk/src/room/mod.rs @@ -1404,10 +1404,10 @@ impl Room { /// /// # Arguments /// - /// * `content` - The content of the event as a json `Value`. - /// /// * `event_type` - The type of the event. /// + /// * `content` - The content of the event as a json `Value`. + /// /// # Examples /// /// ```no_run @@ -1421,20 +1421,16 @@ impl Room { /// # let room_id = room_id!("!test:localhost"); /// use serde_json::json; /// - /// let content = json!({ - /// "body": "Hello world", - /// }); - /// /// if let Some(room) = client.get_room(&room_id) { - /// room.send_raw(content, "m.room.message").await?; + /// room.send_raw("m.room.message", json!({ "body": "Hello world" })).await?; /// } /// # anyhow::Ok(()) }; /// ``` #[instrument(skip_all, fields(event_type, room_id = ?self.room_id(), transaction_id, encrypted))] pub fn send_raw<'a>( &'a self, - content: serde_json::Value, event_type: &'a str, + content: serde_json::Value, ) -> SendRawMessageLikeEvent<'a> { SendRawMessageLikeEvent::new(self, event_type, content) } diff --git a/crates/matrix-sdk/src/widget/matrix.rs b/crates/matrix-sdk/src/widget/matrix.rs index 8faed6a85..0f916314d 100644 --- a/crates/matrix-sdk/src/widget/matrix.rs +++ b/crates/matrix-sdk/src/widget/matrix.rs @@ -116,7 +116,7 @@ impl MatrixDriver { let type_str = event_type.to_string(); Ok(match state_key { Some(key) => self.room.send_state_event_raw(content, &type_str, &key).await?.event_id, - None => self.room.send_raw(content, &type_str).await?.event_id, + None => self.room.send_raw(&type_str, content).await?.event_id, }) }