Skip to content

Commit 5cf74c2

Browse files
authored
Fix bug when rejecting withdrew invite with a third_party_rules module (#17930)
When rejecting a withdrew invite through federation, an out of band event needs to be created. When doing so with a third_party_rules module installed, `get_prev_state_ids` [is called](https://github.com/element-hq/synapse/blob/e0fdb862cbbddc920a30233024eb99038ee2fb28/synapse/module_api/callbacks/third_party_event_rules_callbacks.py#L285) on the context to calculate the state to pass at `check_event_allowed` callbacks. The context for outliers is defined [here](https://github.com/element-hq/synapse/blob/e0fdb862cbbddc920a30233024eb99038ee2fb28/synapse/events/snapshot.py#L168), and `state_group_before_event` is None. This change makes the behavior of `get_prev_state_ids` and `get_current_state_ids` match the one presented in the docstring regarding null state_group.
1 parent adce8a0 commit 5cf74c2

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

changelog.d/17930.bugfix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix bug when rejecting withdrew invite with a third_party_rules module, where the invite would be stuck for the client.

synapse/events/snapshot.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -248,21 +248,20 @@ def state_group(self) -> Optional[int]:
248248
@tag_args
249249
async def get_current_state_ids(
250250
self, state_filter: Optional["StateFilter"] = None
251-
) -> Optional[StateMap[str]]:
251+
) -> StateMap[str]:
252252
"""
253253
Gets the room state map, including this event - ie, the state in ``state_group``
254254
255255
It is an error to access this for a rejected event, since rejected state should
256256
not make it into the room state. This method will raise an exception if
257257
``rejected`` is set.
258258
259+
It is also an error to access this for an outlier event.
260+
259261
Arg:
260262
state_filter: specifies the type of state event to fetch from DB, example: EventTypes.JoinRules
261263
262264
Returns:
263-
Returns None if state_group is None, which happens when the associated
264-
event is an outlier.
265-
266265
Maps a (type, state_key) to the event ID of the state event matching
267266
this tuple.
268267
"""
@@ -300,7 +299,8 @@ async def get_prev_state_ids(
300299
this tuple.
301300
"""
302301

303-
assert self.state_group_before_event is not None
302+
if self.state_group_before_event is None:
303+
return {}
304304
return await self._storage.state.get_state_ids_for_group(
305305
self.state_group_before_event, state_filter
306306
)

0 commit comments

Comments
 (0)