add some accessors to Ar for common patterns

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk 2024-10-24 12:03:56 +00:00
parent 60cc07134f
commit ee92a33a4d
17 changed files with 109 additions and 147 deletions

View file

@ -13,12 +13,10 @@ use crate::Ruma;
pub(crate) async fn get_missing_events_route(
State(services): State<crate::State>, body: Ruma<get_missing_events::v1::Request>,
) -> Result<get_missing_events::v1::Response> {
let origin = body.origin.as_ref().expect("server is authenticated");
services
.rooms
.event_handler
.acl_check(origin, &body.room_id)
.acl_check(body.origin(), &body.room_id)
.await?;
if !services
@ -28,7 +26,7 @@ pub(crate) async fn get_missing_events_route(
.await && !services
.rooms
.state_cache
.server_in_room(origin, &body.room_id)
.server_in_room(body.origin(), &body.room_id)
.await
{
return Err(Error::BadRequest(ErrorKind::forbidden(), "Server is not in room"));
@ -71,7 +69,7 @@ pub(crate) async fn get_missing_events_route(
if !services
.rooms
.state_accessor
.server_can_see_event(origin, &body.room_id, &queued_events[i])
.server_can_see_event(body.origin(), &body.room_id, &queued_events[i])
.await?
{
i = i.saturating_add(1);