File tree 1 file changed +13
-1
lines changed
bindings/matrix-sdk-ffi/src
1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -51,11 +51,23 @@ impl RoomPreview {
51
51
/// Leave the room if the room preview state is either joined, invited or
52
52
/// knocked.
53
53
///
54
+ /// If rejecting an invite then also forget it as an extra layer of
55
+ /// protection against spam attacks.
56
+ ///
54
57
/// Will return an error otherwise.
55
58
pub async fn leave ( & self ) -> Result < ( ) , ClientError > {
56
59
let room =
57
60
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 ( ( ) )
59
71
}
60
72
61
73
/// Get the user who created the invite, if any.
You can’t perform that action at this time.
0 commit comments