perf(pr977): Remove redundant ACL check in send_join

This commit is contained in:
nexy7574 2025-09-07 20:26:26 +01:00
commit d1fff1d09f
No known key found for this signature in database

View file

@ -56,8 +56,10 @@ async fn create_join_event(
// We do not add the event_id field to the pdu here because of signature and // We do not add the event_id field to the pdu here because of signature and
// hashes checks // hashes checks
trace!("Getting room version");
let room_version_id = services.rooms.state.get_room_version(room_id).await?; let room_version_id = services.rooms.state.get_room_version(room_id).await?;
trace!("Generating event ID and converting to canonical json");
let Ok((event_id, mut value)) = gen_event_id_canonical_json(pdu, &room_version_id) else { let Ok((event_id, mut value)) = gen_event_id_canonical_json(pdu, &room_version_id) else {
// Event could not be converted to canonical json // Event could not be converted to canonical json
return Err!(Request(BadJson("Could not convert event to canonical json."))); return Err!(Request(BadJson("Could not convert event to canonical json.")));
@ -106,7 +108,6 @@ async fn create_join_event(
))); )));
} }
// ACL check sender user server name
let sender: OwnedUserId = serde_json::from_value( let sender: OwnedUserId = serde_json::from_value(
value value
.get("sender") .get("sender")
@ -116,12 +117,6 @@ async fn create_join_event(
) )
.map_err(|e| err!(Request(BadJson(warn!("sender property is not a valid user ID: {e}")))))?; .map_err(|e| err!(Request(BadJson(warn!("sender property is not a valid user ID: {e}")))))?;
services
.rooms
.event_handler
.acl_check(sender.server_name(), room_id)
.await?;
// check if origin server is trying to send for another server // check if origin server is trying to send for another server
if sender.server_name() != origin { if sender.server_name() != origin {
return Err!(Request(Forbidden("Not allowed to join on behalf of another server."))); return Err!(Request(Forbidden("Not allowed to join on behalf of another server.")));