mirror of
https://mau.dev/maunium/synapse.git
synced 2024-10-01 01:36:05 -04:00
Faster room joins: make /joined_members
block whilst the room is partial stated. (#13514)
This commit is contained in:
parent
5442891cbc
commit
c3516e9dec
1
changelog.d/13514.bugfix
Normal file
1
changelog.d/13514.bugfix
Normal file
@ -0,0 +1 @@
|
|||||||
|
Faster room joins: make `/joined_members` block whilst the room is partial stated.
|
@ -331,7 +331,11 @@ class MessageHandler:
|
|||||||
msg="Getting joined members while not being a current member of the room is forbidden.",
|
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.
|
# 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
|
# This can either be because the AS user is in the room or because there
|
||||||
|
@ -30,6 +30,7 @@ from typing import (
|
|||||||
from synapse.api.constants import EventTypes
|
from synapse.api.constants import EventTypes
|
||||||
from synapse.events import EventBase
|
from synapse.events import EventBase
|
||||||
from synapse.logging.opentracing import trace
|
from synapse.logging.opentracing import trace
|
||||||
|
from synapse.storage.roommember import ProfileInfo
|
||||||
from synapse.storage.state import StateFilter
|
from synapse.storage.state import StateFilter
|
||||||
from synapse.storage.util.partial_state_events_tracker import (
|
from synapse.storage.util.partial_state_events_tracker import (
|
||||||
PartialCurrentStateTracker,
|
PartialCurrentStateTracker,
|
||||||
@ -506,3 +507,15 @@ class StateStorageController:
|
|||||||
await self._partial_state_room_tracker.await_full_state(room_id)
|
await self._partial_state_room_tracker.await_full_state(room_id)
|
||||||
|
|
||||||
return await self.stores.main.get_current_hosts_in_room(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.
|
||||||
|
If the room is currently partial-stated, this will block until the room has
|
||||||
|
full state.
|
||||||
|
"""
|
||||||
|
await self._partial_state_room_tracker.await_full_state(room_id)
|
||||||
|
|
||||||
|
return await self.stores.main.get_users_in_room_with_profiles(room_id)
|
||||||
|
@ -283,6 +283,9 @@ class RoomMemberWorkerStore(EventsWorkerStore):
|
|||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
A mapping from user ID to ProfileInfo.
|
A mapping from user ID to ProfileInfo.
|
||||||
|
|
||||||
|
Preconditions:
|
||||||
|
- There is full state available for the room (it is not partial-stated).
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def _get_users_in_room_with_profiles(
|
def _get_users_in_room_with_profiles(
|
||||||
|
Loading…
Reference in New Issue
Block a user