diff options
author | Eric Eastwood <eric.eastwood@beta.gouv.fr> | 2024-07-04 12:25:36 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-04 12:25:36 -0500 |
commit | 22aeb78b775ab1d24401b44d642eacc8b99a64fd (patch) | |
tree | d0bf200e3ae91dcc953fba514319b4e2138a9b51 /synapse/storage | |
parent | Changelog entries only get merged if they have the same content and extension... (diff) | |
download | synapse-22aeb78b775ab1d24401b44d642eacc8b99a64fd.tar.xz |
Add `rooms.required_state` to Sliding Sync `/sync` (#17342)
Also handles excluding rooms with partial state when people are asking for room membership events unless it's `$LAZY` room membership.
Diffstat (limited to 'synapse/storage')
-rw-r--r-- | synapse/storage/controllers/state.py | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/synapse/storage/controllers/state.py b/synapse/storage/controllers/state.py index f3630fbbf1..b50eb8868e 100644 --- a/synapse/storage/controllers/state.py +++ b/synapse/storage/controllers/state.py @@ -409,7 +409,7 @@ class StateStorageController: return state_ids - async def get_state_at( + async def get_state_ids_at( self, room_id: str, stream_position: StreamToken, @@ -462,6 +462,30 @@ class StateStorageController: @trace @tag_args + async def get_state_at( + self, + room_id: str, + stream_position: StreamToken, + state_filter: Optional[StateFilter] = None, + await_full_state: bool = True, + ) -> StateMap[EventBase]: + """Same as `get_state_ids_at` but also fetches the events""" + state_map_ids = await self.get_state_ids_at( + room_id, stream_position, state_filter, await_full_state + ) + + event_map = await self.stores.main.get_events(list(state_map_ids.values())) + + state_map = {} + for key, event_id in state_map_ids.items(): + event = event_map.get(event_id) + if event: + state_map[key] = event + + return state_map + + @trace + @tag_args async def get_state_for_groups( self, groups: Iterable[int], state_filter: Optional[StateFilter] = None ) -> Dict[int, MutableStateMap[str]]: |