diff options
author | Patrick Cloke <patrickc@matrix.org> | 2023-07-18 10:12:55 -0400 |
---|---|---|
committer | Patrick Cloke <patrickc@matrix.org> | 2023-07-18 10:12:55 -0400 |
commit | ab75a7d2ac67dbf36da14c723af70d8ec244bf29 (patch) | |
tree | 8092ceec678bac80148095ba76d4c00254692142 /synapse/events/builder.py | |
parent | Remove unsigned and depth in more places. (diff) | |
download | synapse-ab75a7d2ac67dbf36da14c723af70d8ec244bf29.tar.xz |
Fix creating events from LPDUs.
Diffstat (limited to 'synapse/events/builder.py')
-rw-r--r-- | synapse/events/builder.py | 31 |
1 files changed, 17 insertions, 14 deletions
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), ) |