Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit 9633eb2

Browse files
Allow non-member state sent in room batch to resolve for historic events (MSC2716) (#12329)
Part of #12110 Complement test: matrix-org/complement#354 Previously, they didn't resolve because async `filter_events_for_client` removes all outlier state except for out-of-band membership. And fundamentally, we have the state at these events so they shouldn't be marked as outliers.
1 parent b446c99 commit 9633eb2

File tree

2 files changed

+13
-26
lines changed

2 files changed

+13
-26
lines changed

changelog.d/12329.bugfix

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix non-member state events not resolving for historical events when used in [MSC2716](https://github.com/matrix-org/matrix-spec-proposals/pull/2716) `/batch_send` `state_events_at_start`.

synapse/handlers/room_batch.py

+12-26
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,8 @@ async def persist_state_events_at_start(
156156
) -> List[str]:
157157
"""Takes all `state_events_at_start` event dictionaries and creates/persists
158158
them in a floating state event chain which don't resolve into the current room
159-
state. They are floating because they reference no prev_events and are marked
160-
as outliers which disconnects them from the normal DAG.
159+
state. They are floating because they reference no prev_events which disconnects
160+
them from the normal DAG.
161161
162162
Args:
163163
state_events_at_start:
@@ -213,31 +213,23 @@ async def persist_state_events_at_start(
213213
room_id=room_id,
214214
action=membership,
215215
content=event_dict["content"],
216-
# Mark as an outlier to disconnect it from the normal DAG
217-
# and not show up between batches of history.
218-
outlier=True,
219216
historical=True,
220217
# Only the first event in the state chain should be floating.
221218
# The rest should hang off each other in a chain.
222219
allow_no_prev_events=index == 0,
223220
prev_event_ids=prev_event_ids_for_state_chain,
224-
# Since each state event is marked as an outlier, the
225-
# `EventContext.for_outlier()` won't have any `state_ids`
226-
# set and therefore can't derive any state even though the
227-
# prev_events are set. Also since the first event in the
228-
# state chain is floating with no `prev_events`, it can't
229-
# derive state from anywhere automatically. So we need to
230-
# set some state explicitly.
221+
# The first event in the state chain is floating with no
222+
# `prev_events` which means it can't derive state from
223+
# anywhere automatically. So we need to set some state
224+
# explicitly.
231225
#
232226
# Make sure to use a copy of this list because we modify it
233227
# later in the loop here. Otherwise it will be the same
234-
# reference and also update in the event when we append later.
228+
# reference and also update in the event when we append
229+
# later.
235230
state_event_ids=state_event_ids.copy(),
236231
)
237232
else:
238-
# TODO: Add some complement tests that adds state that is not member joins
239-
# and will use this code path. Maybe we only want to support join state events
240-
# and can get rid of this `else`?
241233
(
242234
event,
243235
_,
@@ -246,21 +238,15 @@ async def persist_state_events_at_start(
246238
state_event["sender"], app_service_requester.app_service
247239
),
248240
event_dict,
249-
# Mark as an outlier to disconnect it from the normal DAG
250-
# and not show up between batches of history.
251-
outlier=True,
252241
historical=True,
253242
# Only the first event in the state chain should be floating.
254243
# The rest should hang off each other in a chain.
255244
allow_no_prev_events=index == 0,
256245
prev_event_ids=prev_event_ids_for_state_chain,
257-
# Since each state event is marked as an outlier, the
258-
# `EventContext.for_outlier()` won't have any `state_ids`
259-
# set and therefore can't derive any state even though the
260-
# prev_events are set. Also since the first event in the
261-
# state chain is floating with no `prev_events`, it can't
262-
# derive state from anywhere automatically. So we need to
263-
# set some state explicitly.
246+
# The first event in the state chain is floating with no
247+
# `prev_events` which means it can't derive state from
248+
# anywhere automatically. So we need to set some state
249+
# explicitly.
264250
#
265251
# Make sure to use a copy of this list because we modify it
266252
# later in the loop here. Otherwise it will be the same

0 commit comments

Comments
 (0)