From 9b096cc67b9a95ca2b5fdee008127f5feb98fd81 Mon Sep 17 00:00:00 2001 From: strawberry Date: Tue, 28 May 2024 18:21:25 -0400 Subject: [PATCH] fix: check if you've left the room before forgetting it Signed-off-by: strawberry --- src/api/client_server/membership.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/api/client_server/membership.rs b/src/api/client_server/membership.rs index 34af9cdf..3b8920f8 100644 --- a/src/api/client_server/membership.rs +++ b/src/api/client_server/membership.rs @@ -509,6 +509,17 @@ pub(crate) async fn unban_user_route(body: Ruma) -> Res pub(crate) async fn forget_room_route(body: Ruma) -> Result { let sender_user = body.sender_user.as_ref().expect("user is authenticated"); + if services() + .rooms + .state_cache + .is_joined(sender_user, &body.room_id)? + { + return Err(Error::BadRequest( + ErrorKind::Unknown, + "You must leave the room before forgetting it", + )); + } + services() .rooms .state_cache