mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-02 12:36:02 -04:00
Wait for lazy join to complete when getting current state (#12872)
This commit is contained in:
parent
782cb7420a
commit
888a29f412
33 changed files with 361 additions and 82 deletions
|
@ -194,6 +194,7 @@ class ModuleApi:
|
|||
self._store: Union[
|
||||
DataStore, "GenericWorkerSlavedStore"
|
||||
] = hs.get_datastores().main
|
||||
self._storage_controllers = hs.get_storage_controllers()
|
||||
self._auth = hs.get_auth()
|
||||
self._auth_handler = auth_handler
|
||||
self._server_name = hs.hostname
|
||||
|
@ -911,7 +912,7 @@ class ModuleApi:
|
|||
The filtered state events in the room.
|
||||
"""
|
||||
state_ids = yield defer.ensureDeferred(
|
||||
self._store.get_filtered_current_state_ids(
|
||||
self._storage_controllers.state.get_current_state_ids(
|
||||
room_id=room_id, state_filter=StateFilter.from_types(types)
|
||||
)
|
||||
)
|
||||
|
@ -1289,20 +1290,16 @@ class ModuleApi:
|
|||
# regardless of their state key
|
||||
]
|
||||
"""
|
||||
state_filter = None
|
||||
if event_filter:
|
||||
# If a filter was provided, turn it into a StateFilter and retrieve a filtered
|
||||
# view of the state.
|
||||
state_filter = StateFilter.from_types(event_filter)
|
||||
state_ids = await self._store.get_filtered_current_state_ids(
|
||||
room_id,
|
||||
state_filter,
|
||||
)
|
||||
else:
|
||||
# If no filter was provided, get the whole state. We could also reuse the call
|
||||
# to get_filtered_current_state_ids above, with `state_filter = StateFilter.all()`,
|
||||
# but get_filtered_current_state_ids isn't cached and `get_current_state_ids`
|
||||
# is, so using the latter when we can is better for perf.
|
||||
state_ids = await self._store.get_current_state_ids(room_id)
|
||||
|
||||
state_ids = await self._storage_controllers.state.get_current_state_ids(
|
||||
room_id,
|
||||
state_filter,
|
||||
)
|
||||
|
||||
state_events = await self._store.get_events(state_ids.values())
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue