Skip to content

Commit 57f6f59

Browse files
authored
Make _get_state_map_for_room not break when room state events don't contain an event id. (matrix-org#13174)
Method `_get_state_map_for_room` seems to break in presence of some ill-formed events in the database. Reimplementing this method to use `get_current_state`, which is more robust to such events.
1 parent dcc7873 commit 57f6f59

File tree

2 files changed

+2
-8
lines changed

2 files changed

+2
-8
lines changed

changelog.d/13174.bugfix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Make use of the more robust `get_current_state` in `_get_state_map_for_room` to avoid breakages.

synapse/events/third_party_rules.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -464,14 +464,7 @@ async def _get_state_map_for_room(self, room_id: str) -> StateMap[EventBase]:
464464
Returns:
465465
A dict mapping (event type, state key) to state event.
466466
"""
467-
state_ids = await self._storage_controllers.state.get_current_state_ids(room_id)
468-
room_state_events = await self.store.get_events(state_ids.values())
469-
470-
state_events = {}
471-
for key, event_id in state_ids.items():
472-
state_events[key] = room_state_events[event_id]
473-
474-
return state_events
467+
return await self._storage_controllers.state.get_current_state(room_id)
475468

476469
async def on_profile_update(
477470
self, user_id: str, new_profile: ProfileInfo, by_admin: bool, deactivation: bool

0 commit comments

Comments
 (0)