1
0

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.
This commit is contained in:
Andrew Morgan
2023-07-20 18:02:35 +01:00
parent ebb76e6917
commit 73589e86ef
2 changed files with 6 additions and 4 deletions

View File

@@ -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)

View File

@@ -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: