only sign send_join event if room using restricted joins

Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
strawberry 2024-12-07 01:07:01 -05:00
parent f6b7689b8e
commit cb5443fc64
No known key found for this signature in database

View file

@ -131,13 +131,14 @@ async fn create_join_event(
)); ));
}; };
if content let should_sign_join_event = content
.join_authorized_via_users_server .join_authorized_via_users_server
.is_some_and(|user| services.globals.user_is_local(&user)) .is_some_and(|user| services.globals.user_is_local(&user))
&& super::user_can_perform_restricted_join(services, &sender, room_id, &room_version_id) && super::user_can_perform_restricted_join(services, &sender, room_id, &room_version_id)
.await .await
.unwrap_or_default() .unwrap_or_default();
{
if should_sign_join_event {
services services
.server_keys .server_keys
.hash_and_sign_event(&mut value, &room_version_id) .hash_and_sign_event(&mut value, &room_version_id)
@ -214,8 +215,12 @@ async fn create_join_event(
Ok(create_join_event::v1::RoomState { Ok(create_join_event::v1::RoomState {
auth_chain, auth_chain,
state, state,
// Event field is required if the room version supports restricted join rules. // Event field is required if the room is using restricted join rules and we sign the event
event: to_raw_value(&CanonicalJsonValue::Object(value)).ok(), event: if should_sign_join_event {
to_raw_value(&CanonicalJsonValue::Object(value)).ok()
} else {
None
},
}) })
} }