From fd96f597cd358b9cf83e7878f1f4a6ef01859065 Mon Sep 17 00:00:00 2001 From: strawberry Date: Fri, 9 Aug 2024 16:28:11 -0400 Subject: [PATCH] respect m.room.guest_access on room joins Signed-off-by: strawberry --- src/api/client/membership.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/api/client/membership.rs b/src/api/client/membership.rs index 4b27d8e3..9eb40b4a 100644 --- a/src/api/client/membership.rs +++ b/src/api/client/membership.rs @@ -662,6 +662,12 @@ pub async fn join_room_by_id_helper( ) -> Result { let state_lock = services.rooms.state.mutex.lock(room_id).await; + let user_is_guest = services.users.is_deactivated(sender_user).unwrap_or(false); + + if matches!(services.rooms.state_accessor.guest_can_join(room_id), Ok(false)) && user_is_guest { + return Err!(Request(Forbidden("Guests are not allowed to join this room"))); + } + if matches!(services.rooms.state_cache.is_joined(sender_user, room_id), Ok(true)) { debug_warn!("{sender_user} is already joined in {room_id}"); return Ok(join_room_by_id::v3::Response {