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

Commit c3516e9

Browse files
authored
Faster room joins: make /joined_members block whilst the room is partial stated. (#13514)
1 parent 5442891 commit c3516e9

File tree

4 files changed

+22
-1
lines changed

4 files changed

+22
-1
lines changed

changelog.d/13514.bugfix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Faster room joins: make `/joined_members` block whilst the room is partial stated.

synapse/handlers/message.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,11 @@ async def get_joined_members(self, requester: Requester, room_id: str) -> dict:
331331
msg="Getting joined members while not being a current member of the room is forbidden.",
332332
)
333333

334-
users_with_profile = await self.store.get_users_in_room_with_profiles(room_id)
334+
users_with_profile = (
335+
await self._state_storage_controller.get_users_in_room_with_profiles(
336+
room_id
337+
)
338+
)
335339

336340
# If this is an AS, double check that they are allowed to see the members.
337341
# This can either be because the AS user is in the room or because there

synapse/storage/controllers/state.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
from synapse.api.constants import EventTypes
3131
from synapse.events import EventBase
3232
from synapse.logging.opentracing import trace
33+
from synapse.storage.roommember import ProfileInfo
3334
from synapse.storage.state import StateFilter
3435
from synapse.storage.util.partial_state_events_tracker import (
3536
PartialCurrentStateTracker,
@@ -506,3 +507,15 @@ async def get_current_hosts_in_room(self, room_id: str) -> Set[str]:
506507
await self._partial_state_room_tracker.await_full_state(room_id)
507508

508509
return await self.stores.main.get_current_hosts_in_room(room_id)
510+
511+
async def get_users_in_room_with_profiles(
512+
self, room_id: str
513+
) -> Dict[str, ProfileInfo]:
514+
"""
515+
Get the current users in the room with their profiles.
516+
If the room is currently partial-stated, this will block until the room has
517+
full state.
518+
"""
519+
await self._partial_state_room_tracker.await_full_state(room_id)
520+
521+
return await self.stores.main.get_users_in_room_with_profiles(room_id)

synapse/storage/databases/main/roommember.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,9 @@ async def get_users_in_room_with_profiles(
283283
284284
Returns:
285285
A mapping from user ID to ProfileInfo.
286+
287+
Preconditions:
288+
- There is full state available for the room (it is not partial-stated).
286289
"""
287290

288291
def _get_users_in_room_with_profiles(

0 commit comments

Comments
 (0)