dedup acl checks
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
71a1285c7b
commit
c5569b4c6e
1 changed files with 12 additions and 27 deletions
|
@ -924,19 +924,6 @@ pub(crate) async fn create_join_event_template_route(
|
||||||
}
|
}
|
||||||
|
|
||||||
let origin = body.origin.as_ref().expect("server is authenticated");
|
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 {
|
if body.user_id.server_name() != origin {
|
||||||
return Err(Error::BadRequest(
|
return Err(Error::BadRequest(
|
||||||
ErrorKind::InvalidParam,
|
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()
|
if services()
|
||||||
.globals
|
.globals
|
||||||
.config
|
.config
|
||||||
|
@ -1440,20 +1433,6 @@ pub(crate) async fn create_leave_event_template_route(
|
||||||
}
|
}
|
||||||
|
|
||||||
let origin = body.origin.as_ref().expect("server is authenticated");
|
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 {
|
if body.user_id.server_name() != origin {
|
||||||
return Err(Error::BadRequest(
|
return Err(Error::BadRequest(
|
||||||
ErrorKind::InvalidParam,
|
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 room_version_id = services().rooms.state.get_room_version(&body.room_id)?;
|
||||||
|
|
||||||
let mutex_state = Arc::clone(
|
let mutex_state = Arc::clone(
|
||||||
|
|
Loading…
Add table
Reference in a new issue