summary refs log tree commit diff
path: root/synapse/api/events/factory.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2014-09-15 13:26:05 +0100
committerErik Johnston <erik@matrix.org>2014-09-15 13:26:11 +0100
commit5bd9369a62c6d6cf677e9eef7d58096449542cdf (patch)
tree96b9ed79f774a2fc38b5a8345385b0246197087b /synapse/api/events/factory.py
parentBF: inviter field has moved to the room root object (diff)
downloadsynapse-5bd9369a62c6d6cf677e9eef7d58096449542cdf.tar.xz
Correctly handle the 'age' key in events and pdus
Diffstat (limited to 'synapse/api/events/factory.py')
-rw-r--r--synapse/api/events/factory.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/synapse/api/events/factory.py b/synapse/api/events/factory.py
index 5e38cdbc44..d3d96d73eb 100644
--- a/synapse/api/events/factory.py
+++ b/synapse/api/events/factory.py
@@ -59,6 +59,14 @@ class EventFactory(object):
         if "ts" not in kwargs:
             kwargs["ts"] = int(self.clock.time_msec())
 
+        # The "age" key is a delta timestamp that should be converted into an
+        # absolute timestamp the minute we see it.
+        if "age" in kwargs:
+            kwargs["age_ts"] = int(self.clock.time_msec()) - int(kwargs["age"])
+            del kwargs["age"]
+        elif "age_ts" not in kwargs:
+            kwargs["age_ts"] = int(self.clock.time_msec())
+
         if etype in self._event_list:
             handler = self._event_list[etype]
         else: