summary refs log tree commit diff
path: root/synapse
diff options
context:
space:
mode:
authorTulir Asokan <tulir@maunium.net>2019-05-24 16:44:04 +0300
committerAndrew Morgan <1342360+anoadragon453@users.noreply.github.com>2019-05-24 14:44:04 +0100
commitdd64b9dbdd9bb6f9ac84d51dd4f4bdb665fcfcb1 (patch)
treec947df3805e76c996438c5c433dc56936aa1832e /synapse
parentAdd missing blank line in config (#5249) (diff)
downloadsynapse-dd64b9dbdd9bb6f9ac84d51dd4f4bdb665fcfcb1.tar.xz
Fix appservice timestamp massaging (#5233)
Signed-off-by: Tulir Asokan <tulir@maunium.net>
Diffstat (limited to 'synapse')
-rw-r--r--synapse/events/builder.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/synapse/events/builder.py b/synapse/events/builder.py
index 1fe995f212..546b6f4982 100644
--- a/synapse/events/builder.py
+++ b/synapse/events/builder.py
@@ -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({})))
 
@@ -142,6 +143,9 @@ class EventBuilder(object):
         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,
@@ -209,6 +213,7 @@ class EventBuilderFactory(object):
             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),
         )
 
 
@@ -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)