diff options
author | Erik Johnston <erikj@jki.re> | 2018-11-09 17:59:34 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-09 17:59:34 +0000 |
commit | db5a1c059ac43d744c341a046cb0af3588056d95 (patch) | |
tree | 737ca24441aa45fab5a6734550b46ee1937f1d19 /synapse/federation/federation_server.py | |
parent | Merge pull request #4168 from matrix-org/babolivier/federation-client-content... (diff) | |
parent | Remove hack to support rejoining rooms (diff) | |
download | synapse-db5a1c059ac43d744c341a046cb0af3588056d95.tar.xz |
Merge pull request #4166 from matrix-org/erikj/drop_unknown_events
Drop incoming events from federation for unknown rooms
Diffstat (limited to 'synapse/federation/federation_server.py')
-rw-r--r-- | synapse/federation/federation_server.py | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/synapse/federation/federation_server.py b/synapse/federation/federation_server.py index fa2cc550e2..98722ae543 100644 --- a/synapse/federation/federation_server.py +++ b/synapse/federation/federation_server.py @@ -162,8 +162,30 @@ class FederationServer(FederationBase): p["age_ts"] = request_time - int(p["age"]) del p["age"] + # We try and pull out an event ID so that if later checks fail we + # can log something sensible. We don't mandate an event ID here in + # case future event formats get rid of the key. + possible_event_id = p.get("event_id", "<Unknown>") + + # Now we get the room ID so that we can check that we know the + # version of the room. + room_id = p.get("room_id") + if not room_id: + logger.info( + "Ignoring PDU as does not have a room_id. Event ID: %s", + possible_event_id, + ) + continue + + try: + # In future we will actually use the room version to parse the + # PDU into an event. + yield self.store.get_room_version(room_id) + except NotFoundError: + logger.info("Ignoring PDU for unknown room_id: %s", room_id) + continue + event = event_from_pdu_json(p) - room_id = event.room_id pdus_by_room.setdefault(room_id, []).append(event) pdu_results = {} |