Skip to content

Commit

Permalink
Fast path
Browse files Browse the repository at this point in the history
  • Loading branch information
erikjohnston committed Oct 3, 2024
1 parent 0d3d22b commit 4b022de
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
10 changes: 6 additions & 4 deletions synapse/handlers/sliding_sync/room_lists.py
Original file line number Diff line number Diff line change
Expand Up @@ -500,11 +500,15 @@ async def _compute_interested_rooms_new_tables(
# depending on the `required_state` requested (see below).
partial_state_rooms = await self.store.get_partial_rooms()

# Fetch any rooms that we have not already fetched from the database.
subscription_sliding_sync_rooms = (
await self.store.get_sliding_sync_room_for_user_batch(
user_id, sync_config.room_subscriptions.keys()
user_id,
sync_config.room_subscriptions.keys()
- room_membership_for_user_map.keys(),
)
)
room_membership_for_user_map.update(subscription_sliding_sync_rooms)

for (
room_id,
Expand All @@ -513,13 +517,11 @@ async def _compute_interested_rooms_new_tables(
# Check if we have a membership for the room, but didn't pull it out
# above. This could be e.g. a leave that we don't pull out by
# default.
current_room_entry = subscription_sliding_sync_rooms.get(room_id)
current_room_entry = room_membership_for_user_map.get(room_id)
if not current_room_entry:
# TODO: Handle rooms the user isn't in.
continue

room_membership_for_user_map[room_id] = current_room_entry

all_rooms.add(room_id)

# Take the superset of the `RoomSyncConfig` for each room.
Expand Down
3 changes: 3 additions & 0 deletions synapse/storage/databases/main/roommember.py
Original file line number Diff line number Diff line change
Expand Up @@ -1504,6 +1504,9 @@ async def get_sliding_sync_room_for_user_batch(
) -> Dict[str, RoomsForUserSlidingSync]:
"""Get the sliding sync room entry for the given user and rooms."""

if not room_ids:
return {}

def get_sliding_sync_room_for_user_batch_txn(
txn: LoggingTransaction,
) -> Dict[str, RoomsForUserSlidingSync]:
Expand Down

0 comments on commit 4b022de

Please sign in to comment.