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

Commit

Permalink
Exclude OOB memberships from the federation sender
Browse files Browse the repository at this point in the history
As the comment says, there is no need to process such events, and indeed we
need to avoid doing so.

Fixes #12509.
  • Loading branch information
richvdh committed Apr 27, 2022
1 parent 78b99de commit 78dad8a
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
1 change: 1 addition & 0 deletions changelog.d/12570.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix a bug introduced in Synapse 1.57 which could cause `Failed to calculate hosts in room` errors to be logged for outbound federation.
33 changes: 33 additions & 0 deletions synapse/federation/sender/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,39 @@ async def handle_event(event: EventBase) -> None:
if not is_mine and send_on_behalf_of is None:
return

# We also want to not send out-of-band membership events.
#
# OOB memberships are used in three (and a half) situations:
#
# (1) invite events which we have received over federation. Those
# will have a `sender` on a different server, so will be
# skipped by the "is_mine" test above anyway.
#
# (2) rejections of invites to federated rooms. These are normally
# created via federation (in which case the remote server is
# responsible for sending out the rejection). If that fails,
# we'll create a leave event locally, but that's only really
# for the benefit of the invited user - we don't have enough
# information to send it out over federation.
#
# (2a) rescinded knocks. These are identical to rejected invites.
#
# (3) knock events which we have sent over federation. As with
# invite rejections, the remote server should send them out to
# the federation.
#
# So, in all the above cases, we want to ignore such events.
#
# OOB memberships are always(?) outliers anyway, so if we *don't*
# ignore them, we'll get an exception further down when we try to
# fetch the membership list for the room.
#
if event.internal_metadata.is_out_of_band_membership():
return

# Finally, there are some other events that we should not send out
# until someone asks for them. They are explicitly flagged as such
# with `proactively_send: False`.
if not event.internal_metadata.should_proactively_send():
return

Expand Down

0 comments on commit 78dad8a

Please sign in to comment.