dedup acl checks
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
71a1285c7b
commit
c5569b4c6e
|
@ -924,19 +924,6 @@ pub(crate) async fn create_join_event_template_route(
|
|||
}
|
||||
|
||||
let origin = body.origin.as_ref().expect("server is authenticated");
|
||||
|
||||
// ACL check origin server
|
||||
services()
|
||||
.rooms
|
||||
.event_handler
|
||||
.acl_check(origin, &body.room_id)?;
|
||||
|
||||
// ACL check invited user server name
|
||||
services()
|
||||
.rooms
|
||||
.event_handler
|
||||
.acl_check(body.user_id.server_name(), &body.room_id)?;
|
||||
|
||||
if body.user_id.server_name() != origin {
|
||||
return Err(Error::BadRequest(
|
||||
ErrorKind::InvalidParam,
|
||||
|
@ -944,6 +931,12 @@ pub(crate) async fn create_join_event_template_route(
|
|||
));
|
||||
}
|
||||
|
||||
// ACL check origin server
|
||||
services()
|
||||
.rooms
|
||||
.event_handler
|
||||
.acl_check(origin, &body.room_id)?;
|
||||
|
||||
if services()
|
||||
.globals
|
||||
.config
|
||||
|
@ -1440,20 +1433,6 @@ pub(crate) async fn create_leave_event_template_route(
|
|||
}
|
||||
|
||||
let origin = body.origin.as_ref().expect("server is authenticated");
|
||||
|
||||
// ACL check origin
|
||||
services()
|
||||
.rooms
|
||||
.event_handler
|
||||
.acl_check(origin, &body.room_id)?;
|
||||
|
||||
// ACL check invited user server name
|
||||
services()
|
||||
.rooms
|
||||
.event_handler
|
||||
.acl_check(body.user_id.server_name(), &body.room_id)?;
|
||||
|
||||
// check if origin server is trying to send for another server
|
||||
if body.user_id.server_name() != origin {
|
||||
return Err(Error::BadRequest(
|
||||
ErrorKind::InvalidParam,
|
||||
|
@ -1461,6 +1440,12 @@ pub(crate) async fn create_leave_event_template_route(
|
|||
));
|
||||
}
|
||||
|
||||
// ACL check origin
|
||||
services()
|
||||
.rooms
|
||||
.event_handler
|
||||
.acl_check(origin, &body.room_id)?;
|
||||
|
||||
let room_version_id = services().rooms.state.get_room_version(&body.room_id)?;
|
||||
|
||||
let mutex_state = Arc::clone(
|
||||
|
|
Loading…
Reference in New Issue