mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2025-07-07 23:26:24 +02:00
only sign send_join event if room using restricted joins
Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
parent
f6b7689b8e
commit
cb5443fc64
1 changed files with 10 additions and 5 deletions
|
@ -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
|
||||||
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue