Allow non-member state sent in room batch to resolve for historic events (MSC2716) (#12329)
Part of https://github.com/matrix-org/synapse/issues/12110 Complement test: https://github.com/matrix-org/complement/pull/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.
This commit is contained in:
parent
b446c99ac9
commit
9633eb2162
|
@ -0,0 +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`.
|
|
@ -156,8 +156,8 @@ class RoomBatchHandler:
|
||||||
) -> List[str]:
|
) -> List[str]:
|
||||||
"""Takes all `state_events_at_start` event dictionaries and creates/persists
|
"""Takes all `state_events_at_start` event dictionaries and creates/persists
|
||||||
them in a floating state event chain which don't resolve into the current room
|
them in a floating state event chain which don't resolve into the current room
|
||||||
state. They are floating because they reference no prev_events and are marked
|
state. They are floating because they reference no prev_events which disconnects
|
||||||
as outliers which disconnects them from the normal DAG.
|
them from the normal DAG.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
state_events_at_start:
|
state_events_at_start:
|
||||||
|
@ -213,31 +213,23 @@ class RoomBatchHandler:
|
||||||
room_id=room_id,
|
room_id=room_id,
|
||||||
action=membership,
|
action=membership,
|
||||||
content=event_dict["content"],
|
content=event_dict["content"],
|
||||||
# Mark as an outlier to disconnect it from the normal DAG
|
|
||||||
# and not show up between batches of history.
|
|
||||||
outlier=True,
|
|
||||||
historical=True,
|
historical=True,
|
||||||
# Only the first event in the state chain should be floating.
|
# Only the first event in the state chain should be floating.
|
||||||
# The rest should hang off each other in a chain.
|
# The rest should hang off each other in a chain.
|
||||||
allow_no_prev_events=index == 0,
|
allow_no_prev_events=index == 0,
|
||||||
prev_event_ids=prev_event_ids_for_state_chain,
|
prev_event_ids=prev_event_ids_for_state_chain,
|
||||||
# Since each state event is marked as an outlier, the
|
# The first event in the state chain is floating with no
|
||||||
# `EventContext.for_outlier()` won't have any `state_ids`
|
# `prev_events` which means it can't derive state from
|
||||||
# set and therefore can't derive any state even though the
|
# anywhere automatically. So we need to set some state
|
||||||
# prev_events are set. Also since the first event in the
|
# explicitly.
|
||||||
# state chain is floating with no `prev_events`, it can't
|
|
||||||
# derive state from anywhere automatically. So we need to
|
|
||||||
# set some state explicitly.
|
|
||||||
#
|
#
|
||||||
# Make sure to use a copy of this list because we modify it
|
# Make sure to use a copy of this list because we modify it
|
||||||
# later in the loop here. Otherwise it will be the same
|
# later in the loop here. Otherwise it will be the same
|
||||||
# reference and also update in the event when we append later.
|
# reference and also update in the event when we append
|
||||||
|
# later.
|
||||||
state_event_ids=state_event_ids.copy(),
|
state_event_ids=state_event_ids.copy(),
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
# TODO: Add some complement tests that adds state that is not member joins
|
|
||||||
# and will use this code path. Maybe we only want to support join state events
|
|
||||||
# and can get rid of this `else`?
|
|
||||||
(
|
(
|
||||||
event,
|
event,
|
||||||
_,
|
_,
|
||||||
|
@ -246,21 +238,15 @@ class RoomBatchHandler:
|
||||||
state_event["sender"], app_service_requester.app_service
|
state_event["sender"], app_service_requester.app_service
|
||||||
),
|
),
|
||||||
event_dict,
|
event_dict,
|
||||||
# Mark as an outlier to disconnect it from the normal DAG
|
|
||||||
# and not show up between batches of history.
|
|
||||||
outlier=True,
|
|
||||||
historical=True,
|
historical=True,
|
||||||
# Only the first event in the state chain should be floating.
|
# Only the first event in the state chain should be floating.
|
||||||
# The rest should hang off each other in a chain.
|
# The rest should hang off each other in a chain.
|
||||||
allow_no_prev_events=index == 0,
|
allow_no_prev_events=index == 0,
|
||||||
prev_event_ids=prev_event_ids_for_state_chain,
|
prev_event_ids=prev_event_ids_for_state_chain,
|
||||||
# Since each state event is marked as an outlier, the
|
# The first event in the state chain is floating with no
|
||||||
# `EventContext.for_outlier()` won't have any `state_ids`
|
# `prev_events` which means it can't derive state from
|
||||||
# set and therefore can't derive any state even though the
|
# anywhere automatically. So we need to set some state
|
||||||
# prev_events are set. Also since the first event in the
|
# explicitly.
|
||||||
# state chain is floating with no `prev_events`, it can't
|
|
||||||
# derive state from anywhere automatically. So we need to
|
|
||||||
# set some state explicitly.
|
|
||||||
#
|
#
|
||||||
# Make sure to use a copy of this list because we modify it
|
# Make sure to use a copy of this list because we modify it
|
||||||
# later in the loop here. Otherwise it will be the same
|
# later in the loop here. Otherwise it will be the same
|
||||||
|
|
Loading…
Reference in New Issue