From 40c93b094e8d9ddc7806d0707a873af43bbaeb62 Mon Sep 17 00:00:00 2001 From: Doug Date: Tue, 28 Jan 2025 12:02:11 +0000 Subject: [PATCH] feat: Add a method to remove the room topic. --- bindings/matrix-sdk-ffi/src/room.rs | 6 ++++++ crates/matrix-sdk/src/room/mod.rs | 13 +++++++++++++ 2 files changed, 19 insertions(+) diff --git a/bindings/matrix-sdk-ffi/src/room.rs b/bindings/matrix-sdk-ffi/src/room.rs index 818ac3ff332..749957dd8b5 100644 --- a/bindings/matrix-sdk-ffi/src/room.rs +++ b/bindings/matrix-sdk-ffi/src/room.rs @@ -428,6 +428,12 @@ impl Room { Ok(()) } + /// Removes the topic from the room if one is set. + pub async fn remove_topic(&self) -> Result<(), ClientError> { + self.inner.remove_room_topic().await?; + Ok(()) + } + /// Upload and set the room's avatar. /// /// This will upload the data produced by the reader to the homeserver's diff --git a/crates/matrix-sdk/src/room/mod.rs b/crates/matrix-sdk/src/room/mod.rs index c9b60222c41..15c14ca9d78 100644 --- a/crates/matrix-sdk/src/room/mod.rs +++ b/crates/matrix-sdk/src/room/mod.rs @@ -2270,6 +2270,19 @@ impl Room { self.send_state_event(RoomTopicEventContent::new(topic.into())).await } + /// Removes the topic from this room if one is set. + pub async fn remove_room_topic(&self) -> Result<()> { + let event = self + .get_state_event_static::() + .await? + .ok_or(Error::InsufficientData)? + .deserialize()?; + let event_id = event.event_id().ok_or(Error::InsufficientData)?; + + self.redact(event_id, None, None).await.map_err(Error::Http)?; + Ok(()) + } + /// Sets the new avatar url for this room. /// /// # Arguments