diff --git a/src/api/server_server.rs b/src/api/server_server.rs index 08fecba3..89d1b267 100644 --- a/src/api/server_server.rs +++ b/src/api/server_server.rs @@ -1058,6 +1058,23 @@ fn get_missing_events( latest_events: &[OwnedEventId], limit: UInt, ) -> Result>> { + let (room_members, room_errors): (Vec<_>, Vec<_>) = services() + .rooms + .state_cache + .room_members(room_id) + .partition(Result::is_ok); + + // Just log errors and continue with correct users + if !room_errors.is_empty() { + warn!(?room_id, "Some errors occurred when fetching room members"); + } + + let current_server_members: Vec = room_members + .into_iter() + .map(Result::unwrap) + .filter(|member| member.server_name() == sender_servername) + .collect(); + let limit = u64::from(limit) as usize; let mut queued_events = latest_events.to_owned(); @@ -1094,23 +1111,6 @@ fn get_missing_events( )); } - let (room_members, room_errors): (Vec<_>, Vec<_>) = services() - .rooms - .state_cache - .room_members(room_id) - .partition(Result::is_ok); - - // Just log errors and continue with correct users - if !room_errors.is_empty() { - warn!(?room_id, "Some errors occurred when fetching room members"); - } - - let current_server_members: Vec = room_members - .into_iter() - .map(Result::unwrap) - .filter(|member| member.server_name() == sender_servername) - .collect(); - let event_is_visible = services().rooms.state_accessor.server_can_see_event( sender_servername, current_server_members.as_slice(),