From 8ef6f02ee9705ab0c1fdf3332246e78c24f4608b Mon Sep 17 00:00:00 2001 From: Jonathan Sutton Date: Tue, 17 Mar 2026 02:13:40 -0500 Subject: [PATCH] fix(room_member): Strip join_authorized_via_users_server (#1542) Some clients were sending join_authorized_via_users_server when they were already in the room, to change nicknames. This caused an undesirable error, so a check for if they were already in the room was moved and changed to strip from metadata before attempting to process metadata. Signed-off-by: Jonathan Sutton --- src/api/client/state.rs | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/src/api/client/state.rs b/src/api/client/state.rs index 323d07189..460521d2d 100644 --- a/src/api/client/state.rs +++ b/src/api/client/state.rs @@ -366,14 +366,23 @@ async fn allowed_to_send_state_event( } }, | StateEventType::RoomMember => match json.deserialize_as::() { - | Ok(membership_content) => { + | Ok(mut membership_content) => { let Ok(state_key) = UserId::parse(state_key) else { return Err!(Request(BadJson( "Membership event has invalid or non-existent state key" ))); }; - if let Some(authorising_user) = + // Moved the check for if user is already joined and then stripped the Option + // Unsure if this actually fixes it + if services + .rooms + .state_cache + .is_joined(state_key, room_id) + .await + { + membership_content.join_authorized_via_users_server.take(); + } else if let Some(authorising_user) = membership_content.join_authorized_via_users_server { if membership_content.membership != MembershipState::Join { @@ -382,17 +391,6 @@ async fn allowed_to_send_state_event( ))); } - if services - .rooms - .state_cache - .is_joined(state_key, room_id) - .await - { - return Err!(Request(InvalidParam( - "{state_key} is already joined, an authorising user is not required." - ))); - } - if !services.globals.user_is_local(&authorising_user) { return Err!(Request(InvalidParam( "Authorising user {authorising_user} does not belong to this \