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

Commit

Permalink
Fix appservice timestamp massaging (#5233)
Browse files Browse the repository at this point in the history
Signed-off-by: Tulir Asokan <tulir@maunium.net>
  • Loading branch information
tulir authored and anoadragon453 committed May 24, 2019
1 parent dba9152 commit dd64b9d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
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

0 comments on commit dd64b9d

Please sign in to comment.