Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add a method to remove the room topic. #4589

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions bindings/matrix-sdk-ffi/src/room.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions crates/matrix-sdk/src/room/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a smoke test to check that this calls the correct requests? The MatrixMockServer should make this relatively easy.

Let me know if you need some guidance on how the MatrixMockServer is supposed to be used.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah nice. Just waiting to hear back if we actually want this method now given element-hq/element-meta#2705 (comment). Will come back and add that test if we do 👍

.get_state_event_static::<RoomTopicEventContent>()
.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
Expand Down
Loading