Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Fix appservice timestamp massaging #5233

Merged
merged 1 commit into from
May 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/5233.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix appservice timestamp massaging.
7 changes: 6 additions & 1 deletion synapse/events/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ class EventBuilder(object):
# someone tries to get them when they don't exist.
_state_key = attr.ib(default=None)
_redacts = attr.ib(default=None)
_origin_server_ts = attr.ib(default=None)

internal_metadata = attr.ib(default=attr.Factory(lambda: _EventInternalMetadata({})))

Expand Down Expand Up @@ -142,6 +143,9 @@ def build(self, prev_event_ids):
if self._redacts is not None:
event_dict["redacts"] = self._redacts

if self._origin_server_ts is not None:
event_dict["origin_server_ts"] = self._origin_server_ts

defer.returnValue(
create_local_event_from_event_dict(
clock=self._clock,
Expand Down Expand Up @@ -209,6 +213,7 @@ def for_room_version(self, room_version, key_values):
content=key_values.get("content", {}),
unsigned=key_values.get("unsigned", {}),
redacts=key_values.get("redacts", None),
origin_server_ts=key_values.get("origin_server_ts", None),
)


Expand Down Expand Up @@ -245,7 +250,7 @@ def create_local_event_from_event_dict(clock, hostname, signing_key,
event_dict["event_id"] = _create_event_id(clock, hostname)

event_dict["origin"] = hostname
event_dict["origin_server_ts"] = time_now
event_dict.setdefault("origin_server_ts", time_now)

event_dict.setdefault("unsigned", {})
age = event_dict["unsigned"].pop("age", 0)
Expand Down