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 <jonathansutton91@proton.me>
This commit is contained in:
Jonathan Sutton
2026-03-24 13:11:25 +00:00
committed by Ellis Git
parent 11020df89d
commit 8ef6f02ee9
+10 -12
View File
@@ -366,30 +366,28 @@ async fn allowed_to_send_state_event(
} }
}, },
| StateEventType::RoomMember => match json.deserialize_as::<RoomMemberEventContent>() { | StateEventType::RoomMember => match json.deserialize_as::<RoomMemberEventContent>() {
| Ok(membership_content) => { | Ok(mut membership_content) => {
let Ok(state_key) = UserId::parse(state_key) else { let Ok(state_key) = UserId::parse(state_key) else {
return Err!(Request(BadJson( return Err!(Request(BadJson(
"Membership event has invalid or non-existent state key" "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
membership_content.join_authorized_via_users_server // Unsure if this actually fixes it
{
if membership_content.membership != MembershipState::Join {
return Err!(Request(BadJson(
"join_authorised_via_users_server is only for member joins"
)));
}
if services if services
.rooms .rooms
.state_cache .state_cache
.is_joined(state_key, room_id) .is_joined(state_key, room_id)
.await .await
{ {
return Err!(Request(InvalidParam( membership_content.join_authorized_via_users_server.take();
"{state_key} is already joined, an authorising user is not required." } else if let Some(authorising_user) =
membership_content.join_authorized_via_users_server
{
if membership_content.membership != MembershipState::Join {
return Err!(Request(BadJson(
"join_authorised_via_users_server is only for member joins"
))); )));
} }