summary refs log tree commit diff
diff options
context:
space:
mode:
authorAndrew Morgan <andrew@amorgan.xyz>2023-07-20 18:02:35 +0100
committerAndrew Morgan <andrew@amorgan.xyz>2023-07-22 22:29:20 +0100
commit73589e86efcee04341e596a94f6490a48eacae48 (patch)
tree76ce1deb856e80ab8870280c5300cc736dd1552a
parentIf we are acting on a PDU, keep the "lpdu" hash intact. (diff)
downloadsynapse-73589e86efcee04341e596a94f6490a48eacae48.tar.xz
Use room version, not "hub_server" field when adding/validating "origin"
As other events sent in a LM room that are not on behalf of
participating servers will not have this field.
-rw-r--r--synapse/events/builder.py5
-rw-r--r--synapse/events/validator.py5
2 files changed, 6 insertions, 4 deletions
diff --git a/synapse/events/builder.py b/synapse/events/builder.py
index ec89eaeb1c..df628c9a61 100644
--- a/synapse/events/builder.py
+++ b/synapse/events/builder.py
@@ -276,8 +276,9 @@ def create_local_event_from_event_dict(
     if format_version == EventFormatVersions.ROOM_V1_V2:
         event_dict["event_id"] = _create_event_id(clock, hostname)
 
-    if "hub_server" not in event_dict:
-        # Do not add "origin" field to LPDUs.
+    if not room_version.linearized_matrix:
+        # Do not add "origin" field to events (LPDUs and PDUs) sent in
+        # rooms that are meant to be compatible with linearized matrix.
         event_dict["origin"] = hostname
 
     event_dict.setdefault("origin_server_ts", time_now)
diff --git a/synapse/events/validator.py b/synapse/events/validator.py
index e3c33d922d..ab8ffc84a8 100644
--- a/synapse/events/validator.py
+++ b/synapse/events/validator.py
@@ -66,8 +66,9 @@ class EventValidator:
             "type",
         ]
 
-        if event.hub_server is not None:
-            # Do not add the "origin" field to LPDUs.
+        if event.room_version.linearized_matrix:
+            # Do not add "origin" field to events (LPDUs and PDUs) sent in
+            # rooms that are meant to be compatible with linearized matrix.
             required.remove("origin")
 
         for k in required: