diff options
author | Andrew Morgan <andrew@amorgan.xyz> | 2023-07-20 17:12:49 +0100 |
---|---|---|
committer | Andrew Morgan <andrew@amorgan.xyz> | 2023-07-20 17:12:49 +0100 |
commit | cbf930edf882054e309327010535ab2e8b206969 (patch) | |
tree | 09dfdf69a664a421608e2805dad4523a5deb0eb2 | |
parent | Fix https://github.com/matrix-org/synapse/issues/15962 (diff) | |
download | synapse-cbf930edf882054e309327010535ab2e8b206969.tar.xz |
Do not add `origin` field to LPDUs.
Synapse has a bad habit of adding `origin` to the top-level of event content. The Linearized Matrix spec does not include `origin`, and in fact cannot as that will cause the content hashes and signatures computed by the participant server to differ from Synapse's own results. So, we perform a hack here to drop `origin` from any event derived from an LPDU event. Other DAG homeserver implementations might be sad however.
-rw-r--r-- | synapse/events/builder.py | 5 | ||||
-rw-r--r-- | synapse/events/validator.py | 4 |
2 files changed, 8 insertions, 1 deletions
diff --git a/synapse/events/builder.py b/synapse/events/builder.py index d93ed095cc..e3b2569f91 100644 --- a/synapse/events/builder.py +++ b/synapse/events/builder.py @@ -276,7 +276,10 @@ def create_local_event_from_event_dict( if format_version == EventFormatVersions.ROOM_V1_V2: event_dict["event_id"] = _create_event_id(clock, hostname) - event_dict["origin"] = hostname + if "hub_server" not in event_dict: + # Do not add "origin" field to LPDUs. + event_dict["origin"] = hostname + event_dict.setdefault("origin_server_ts", time_now) event_dict.setdefault("unsigned", {}) diff --git a/synapse/events/validator.py b/synapse/events/validator.py index 9278f1a1aa..e3c33d922d 100644 --- a/synapse/events/validator.py +++ b/synapse/events/validator.py @@ -66,6 +66,10 @@ class EventValidator: "type", ] + if event.hub_server is not None: + # Do not add the "origin" field to LPDUs. + required.remove("origin") + for k in required: if k not in event: raise SynapseError(400, "Event does not have key %s" % (k,)) |