summary refs log tree commit diff
path: root/synapse/api/events/factory.py
diff options
context:
space:
mode:
authorKegan Dougal <kegan@matrix.org>2014-09-15 15:27:58 +0100
committerKegan Dougal <kegan@matrix.org>2014-09-15 15:27:58 +0100
commit14bc4ed59f0d98e80db96ed8232983f814082305 (patch)
tree27e70665764b41f5f16f8662eb1328e2ba20aba7 /synapse/api/events/factory.py
parentUpdate spec to include m.login.email.identity (diff)
parentCorrectly handle the 'age' key in events and pdus (diff)
downloadsynapse-14bc4ed59f0d98e80db96ed8232983f814082305.tar.xz
Merge branch 'develop' of github.com:matrix-org/synapse into registration-api-changes in preparation for re-merge to develop.
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: