summary refs log tree commit diff
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2014-08-21 17:46:52 +0100
committerErik Johnston <erik@matrix.org>2014-08-21 17:46:52 +0100
commit5670da1c1e1bd9e1f6992b9d5046c21a3a46b810 (patch)
tree55efe86b41e0b84d01949add18315dab93d521b4
parentChange webclient to always hit the im sync api before streaming so we get cur... (diff)
downloadsynapse-5670da1c1e1bd9e1f6992b9d5046c21a3a46b810.tar.xz
Add ts field to all events.
Diffstat (limited to '')
-rw-r--r--synapse/api/events/factory.py7
-rw-r--r--synapse/server.py2
2 files changed, 7 insertions, 2 deletions
diff --git a/synapse/api/events/factory.py b/synapse/api/events/factory.py
index b61dac7acd..c2cdcddf41 100644
--- a/synapse/api/events/factory.py
+++ b/synapse/api/events/factory.py
@@ -33,16 +33,21 @@ class EventFactory(object):
         RoomConfigEvent
     ]
 
-    def __init__(self):
+    def __init__(self, hs):
         self._event_list = {}  # dict of TYPE to event class
         for event_class in EventFactory._event_classes:
             self._event_list[event_class.TYPE] = event_class
 
+        self.clock = hs.get_clock()
+
     def create_event(self, etype=None, **kwargs):
         kwargs["type"] = etype
         if "event_id" not in kwargs:
             kwargs["event_id"] = random_string(10)
 
+        if "ts" not in kwargs:
+            kwargs["ts"] = int(self.clock.time_msec())
+
         if etype in self._event_list:
             handler = self._event_list[etype]
         else:
diff --git a/synapse/server.py b/synapse/server.py
index d4c2481483..c5b0a32757 100644
--- a/synapse/server.py
+++ b/synapse/server.py
@@ -159,7 +159,7 @@ class HomeServer(BaseHomeServer):
         return DataStore(self)
 
     def build_event_factory(self):
-        return EventFactory()
+        return EventFactory(self)
 
     def build_handlers(self):
         return Handlers(self)