From 54b0e52888a0d9c6ee789c400be8f3486d867851 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Tue, 21 Sep 2021 19:16:33 +0100 Subject: [PATCH] Ensure we mark sent knocks as outliers --- changelog.d/10873.bugfix | 1 + synapse/handlers/federation.py | 14 +++++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) create mode 100644 changelog.d/10873.bugfix diff --git a/changelog.d/10873.bugfix b/changelog.d/10873.bugfix new file mode 100644 index 000000000000..32b2e50fd915 --- /dev/null +++ b/changelog.d/10873.bugfix @@ -0,0 +1 @@ +Fix a bug introduced in Synapse 1.37.0 which caused `knock` events which we sent to remote servers to be incorrectly stored in the local database. diff --git a/synapse/handlers/federation.py b/synapse/handlers/federation.py index 8e2cf3387a1b..018a437884cf 100644 --- a/synapse/handlers/federation.py +++ b/synapse/handlers/federation.py @@ -820,9 +820,6 @@ async def do_remotely_reject_invite( origin, event, room_version = await self._make_and_verify_event( target_hosts, room_id, user_id, "leave", content=content ) - # Mark as outlier as we don't have any state for this event; we're not - # even in the room. - event.internal_metadata.outlier = True event.internal_metadata.out_of_band_membership = True # Try the host that we successfully called /make_leave/ on first for @@ -868,6 +865,17 @@ async def _make_and_verify_event( assert event.user_id == user_id assert event.state_key == user_id assert event.room_id == room_id + + # if this is a proto-join, it will never get peristed in its current form + # (instead we'll end up persisting the event that comes back from /send_join), + # so it doesn't really matter if we mark it as an outlier or not, but let's + # do so for consistency. + # + # Otherwise (ie, if it's an invite-rejecting leave or a knock), we need + # to mark it as an outlier because we don't yet know the state at this point + # in the DAG. + event.internal_metadata.outlier = True + return origin, event, room_version async def on_make_leave_request(