Skip to content

Commit ca025f8

Browse files
committed
feat(ffi): forget the room when rejecting invites
- we're doing this as an extra layer of protection against spam attacks.
1 parent 78e19fc commit ca025f8

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

bindings/matrix-sdk-ffi/src/room_preview.rs

+13-1
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,23 @@ impl RoomPreview {
5151
/// Leave the room if the room preview state is either joined, invited or
5252
/// knocked.
5353
///
54+
/// If rejecting an invite then also forget it as an extra layer of
55+
/// protection against spam attacks.
56+
///
5457
/// Will return an error otherwise.
5558
pub async fn leave(&self) -> Result<(), ClientError> {
5659
let room =
5760
self.client.get_room(&self.inner.room_id).context("missing room for a room preview")?;
58-
room.leave().await.map_err(Into::into)
61+
62+
let should_forget = matches!(room.state(), matrix_sdk::RoomState::Invited);
63+
64+
room.leave().await.map_err(ClientError::from)?;
65+
66+
if should_forget {
67+
_ = self.forget().await;
68+
}
69+
70+
Ok(())
5971
}
6072

6173
/// Get the user who created the invite, if any.

0 commit comments

Comments
 (0)