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 authored and Ellis Git committed 2026-03-24 13:11:25 +00:00
1 parent 11020df89d
commit 8ef6f02ee9
1 file changed
+11 -13
+11 -13
View File
@@ -366,14 +366,23 @@ 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
// 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 membership_content.join_authorized_via_users_server
{ {
if membership_content.membership != MembershipState::Join { 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) { if !services.globals.user_is_local(&authorising_user) {
return Err!(Request(InvalidParam( return Err!(Request(InvalidParam(
"Authorising user {authorising_user} does not belong to this \ "Authorising user {authorising_user} does not belong to this \