Skip to content
Snippets Groups Projects
Unverified Commit 318f4e73 authored by Richard van der Hoff's avatar Richard van der Hoff Committed by GitHub
Browse files

Be more tolerant of membership events in unknown rooms (#8110)

It turns out that not all out-of-band membership events are labelled as such,
so we need to be more accepting here.
parent 592cdf73
No related branches found
No related tags found
No related merge requests found
Fix a bug introduced in Synapse 1.12.0 which could cause `/sync` requests to fail with a 404 if you had a very old outstanding room invite.
...@@ -133,6 +133,8 @@ class _EventInternalMetadata(object): ...@@ -133,6 +133,8 @@ class _EventInternalMetadata(object):
rejection. This is needed as those events are marked as outliers, but rejection. This is needed as those events are marked as outliers, but
they still need to be processed as if they're new events (e.g. updating they still need to be processed as if they're new events (e.g. updating
invite state in the database, relaying to clients, etc). invite state in the database, relaying to clients, etc).
(Added in synapse 0.99.0, so may be unreliable for events received before that)
""" """
return self._dict.get("out_of_band_membership", False) return self._dict.get("out_of_band_membership", False)
......
...@@ -620,19 +620,38 @@ class EventsWorkerStore(SQLBaseStore): ...@@ -620,19 +620,38 @@ class EventsWorkerStore(SQLBaseStore):
room_version_id = row["room_version_id"] room_version_id = row["room_version_id"]
if not room_version_id: if not room_version_id:
# this should only happen for out-of-band membership events # this should only happen for out-of-band membership events which
if not internal_metadata.get("out_of_band_membership"): # arrived before #6983 landed. For all other events, we should have
logger.warning( # an entry in the 'rooms' table.
"Room %s for event %s is unknown", d["room_id"], event_id #
# However, the 'out_of_band_membership' flag is unreliable for older
# invites, so just accept it for all membership events.
#
if d["type"] != EventTypes.Member:
raise Exception(
"Room %s for event %s is unknown" % (d["room_id"], event_id)
) )
continue
# take a wild stab at the room version based on the event format # so, assuming this is an out-of-band-invite that arrived before #6983
# landed, we know that the room version must be v5 or earlier (because
# v6 hadn't been invented at that point, so invites from such rooms
# would have been rejected.)
#
# The main reason we need to know the room version here (other than
# choosing the right python Event class) is in case the event later has
# to be redacted - and all the room versions up to v5 used the same
# redaction algorithm.
#
# So, the following approximations should be adequate.
if format_version == EventFormatVersions.V1: if format_version == EventFormatVersions.V1:
# if it's event format v1 then it must be room v1 or v2
room_version = RoomVersions.V1 room_version = RoomVersions.V1
elif format_version == EventFormatVersions.V2: elif format_version == EventFormatVersions.V2:
# if it's event format v2 then it must be room v3
room_version = RoomVersions.V3 room_version = RoomVersions.V3
else: else:
# if it's event format v3 then it must be room v4 or v5
room_version = RoomVersions.V5 room_version = RoomVersions.V5
else: else:
room_version = KNOWN_ROOM_VERSIONS.get(room_version_id) room_version = KNOWN_ROOM_VERSIONS.get(room_version_id)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment