Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Faster room joins: make /joined_members block whilst the room is partial stated. #13514

Merged
merged 3 commits into from
Aug 16, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/13514.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Faster room joins: make `/joined_members` block whilst the room is partial stated.
6 changes: 5 additions & 1 deletion synapse/handlers/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,11 @@ async def get_joined_members(self, requester: Requester, room_id: str) -> dict:
msg="Getting joined members while not being a current member of the room is forbidden.",
)

users_with_profile = await self.store.get_users_in_room_with_profiles(room_id)
users_with_profile = (
await self._state_storage_controller.get_users_in_room_with_profiles(
room_id
)
)

# If this is an AS, double check that they are allowed to see the members.
# This can either be because the AS user is in the room or because there
Expand Down
9 changes: 9 additions & 0 deletions synapse/storage/controllers/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
from synapse.api.constants import EventTypes
from synapse.events import EventBase
from synapse.logging.opentracing import trace
from synapse.storage.roommember import ProfileInfo
from synapse.storage.state import StateFilter
from synapse.storage.util.partial_state_events_tracker import (
PartialCurrentStateTracker,
Expand Down Expand Up @@ -506,3 +507,11 @@ async def get_current_hosts_in_room(self, room_id: str) -> Set[str]:
await self._partial_state_room_tracker.await_full_state(room_id)

return await self.stores.main.get_current_hosts_in_room(room_id)

async def get_users_in_room_with_profiles(
self, room_id: str
) -> Dict[str, ProfileInfo]:
"""Get the current users in the room with their profiles."""
await self._partial_state_room_tracker.await_full_state(room_id)

return await self.stores.main.get_users_in_room_with_profiles(room_id)