From bdd1e9eddb7d455705cb7ee93df9bc1fb93f5c15 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Wed, 10 Jul 2024 15:30:22 +0100 Subject: Fixup --- synapse/handlers/sliding_sync.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'synapse/handlers/sliding_sync.py') diff --git a/synapse/handlers/sliding_sync.py b/synapse/handlers/sliding_sync.py index cbaad11a61..0fb7e05b5d 100644 --- a/synapse/handlers/sliding_sync.py +++ b/synapse/handlers/sliding_sync.py @@ -1012,11 +1012,31 @@ class SlidingSyncHandler: A sorted list of room IDs by `stream_ordering` along with membership information. """ + self.store._events_stream_cache._entity_to_key + # XXX: FIXUP last_activity_in_room_map = await self.store.rough_get_last_pos( - sync_room_map.keys() + [ + room_id + for room_id, room_for_user in sync_room_map.items() + if room_for_user.membership == Membership.JOIN + ] ) + last_activity_in_room_map = {} + to_fetch = [] + for room_id, room_for_user in sync_room_map.items(): + if room_for_user.membership == Membership.JOIN: + stream_pos = self.store._events_stream_cache._entity_to_key.get(room_id) + if stream_pos is not None: + last_activity_in_room_map[room_id] = stream_pos + else: + to_fetch.ap(room_id) + else: + last_activity_in_room_map[room_id] = room_for_user.event_pos.stream + + last_activity_in_room_map.update(await self.store.rough_get_last_pos(to_fetch)) + return sorted( sync_room_map.values(), # Sort by the last activity (stream_ordering) in the room -- cgit 1.5.1