summary refs log tree commit diff
path: root/synapse
diff options
context:
space:
mode:
authorPatrick Cloke <patrickc@matrix.org>2023-07-18 10:12:55 -0400
committerPatrick Cloke <patrickc@matrix.org>2023-07-18 10:12:55 -0400
commitab75a7d2ac67dbf36da14c723af70d8ec244bf29 (patch)
tree8092ceec678bac80148095ba76d4c00254692142 /synapse
parentRemove unsigned and depth in more places. (diff)
downloadsynapse-ab75a7d2ac67dbf36da14c723af70d8ec244bf29.tar.xz
Fix creating events from LPDUs.
Diffstat (limited to 'synapse')
-rw-r--r--synapse/events/__init__.py4
-rw-r--r--synapse/events/builder.py31
-rw-r--r--synapse/federation/federation_server.py3
3 files changed, 22 insertions, 16 deletions
diff --git a/synapse/events/__init__.py b/synapse/events/__init__.py
index 87529854c4..e06bba7afb 100644
--- a/synapse/events/__init__.py
+++ b/synapse/events/__init__.py
@@ -612,6 +612,10 @@ class FrozenLinearizedEvent(FrozenEventV3):
     depth = 0  # type: ignore[assignment]
 
     @property
+    def origin(self) -> str:
+        return get_domain_from_id(self.sender)
+
+    @property
     def pdu_domain(self) -> str:
         """The domain which added this event to the DAG.
 
diff --git a/synapse/events/builder.py b/synapse/events/builder.py
index 94e5688759..084b5291eb 100644
--- a/synapse/events/builder.py
+++ b/synapse/events/builder.py
@@ -148,20 +148,6 @@ class EventBuilder:
             auth_events = auth_event_ids
             prev_events = prev_event_ids
 
-        # Otherwise, progress the depth as normal
-        if depth is None:
-            (
-                _,
-                most_recent_prev_event_depth,
-            ) = await self._store.get_max_depth_of(prev_event_ids)
-
-            depth = most_recent_prev_event_depth + 1
-
-        # we cap depth of generated events, to ensure that they are not
-        # rejected by other servers (and so that they can be persisted in
-        # the db)
-        depth = min(depth, MAX_DEPTH)
-
         event_dict: Dict[str, Any] = {
             "auth_events": auth_events,
             "prev_events": prev_events,
@@ -172,7 +158,23 @@ class EventBuilder:
             "unsigned": self.unsigned,
         }
         if not self.room_version.linearized_matrix:
+            # Otherwise, progress the depth as normal
+            if depth is None:
+                (
+                    _,
+                    most_recent_prev_event_depth,
+                ) = await self._store.get_max_depth_of(prev_event_ids)
+
+                depth = most_recent_prev_event_depth + 1
+
+            # we cap depth of generated events, to ensure that they are not
+            # rejected by other servers (and so that they can be persisted in
+            # the db)
+            depth = min(depth, MAX_DEPTH)
+
             event_dict["depth"] = depth
+        elif self.hub_server is not None:
+            event_dict["hub_server"] = self.hub_server
 
         if self.is_state():
             event_dict["state_key"] = self._state_key
@@ -234,6 +236,7 @@ class EventBuilderFactory:
             unsigned=key_values.get("unsigned", {}),
             redacts=key_values.get("redacts", None),
             origin_server_ts=key_values.get("origin_server_ts", None),
+            hub_server=key_values.get("hub_server", None),
         )
 
 
diff --git a/synapse/federation/federation_server.py b/synapse/federation/federation_server.py
index 6e5fa82a10..2557ba0f80 100644
--- a/synapse/federation/federation_server.py
+++ b/synapse/federation/federation_server.py
@@ -1054,9 +1054,8 @@ class FederationServer(FederationBase):
             lpdu_json,
             (
                 "type",
-                "room_Id",
+                "room_id",
                 "sender",
-                "origin",
                 "hub_server",
                 "origin_server_ts",
                 "content",