summary refs log tree commit diff
path: root/synapse/rest/client/v1/events.py
diff options
context:
space:
mode:
authorDavid Baker <dave@matrix.org>2015-01-28 12:51:05 +0000
committerDavid Baker <dave@matrix.org>2015-01-28 12:51:05 +0000
commitc291a4d522afef7449311673b3863db5e484b6e8 (patch)
treef69458797cfba50c33448a7953e34f3527158154 /synapse/rest/client/v1/events.py
parentReset badge count to zero when last active time is bumped (diff)
parentInitial cut of a shared base class for REST unit tests (diff)
downloadsynapse-c291a4d522afef7449311673b3863db5e484b6e8.tar.xz
Merge branch 'develop' into pushers
Conflicts:
	synapse/handlers/events.py
	synapse/server.py
Diffstat (limited to 'synapse/rest/client/v1/events.py')
-rw-r--r--synapse/rest/client/v1/events.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/synapse/rest/client/v1/events.py b/synapse/rest/client/v1/events.py
index c2515528ac..a0d051227b 100644
--- a/synapse/rest/client/v1/events.py
+++ b/synapse/rest/client/v1/events.py
@@ -18,7 +18,8 @@ from twisted.internet import defer
 
 from synapse.api.errors import SynapseError
 from synapse.streams.config import PaginationConfig
-from .base import RestServlet, client_path_pattern
+from .base import ClientV1RestServlet, client_path_pattern
+from synapse.events.utils import serialize_event
 
 import logging
 
@@ -26,7 +27,7 @@ import logging
 logger = logging.getLogger(__name__)
 
 
-class EventStreamRestServlet(RestServlet):
+class EventStreamRestServlet(ClientV1RestServlet):
     PATTERN = client_path_pattern("/events$")
 
     DEFAULT_LONGPOLL_TIME_MS = 30000
@@ -61,17 +62,22 @@ class EventStreamRestServlet(RestServlet):
 
 
 # TODO: Unit test gets, with and without auth, with different kinds of events.
-class EventRestServlet(RestServlet):
+class EventRestServlet(ClientV1RestServlet):
     PATTERN = client_path_pattern("/events/(?P<event_id>[^/]*)$")
 
+    def __init__(self, hs):
+        super(EventRestServlet, self).__init__(hs)
+        self.clock = hs.get_clock()
+
     @defer.inlineCallbacks
     def on_GET(self, request, event_id):
         auth_user = yield self.auth.get_user_by_req(request)
         handler = self.handlers.event_handler
         event = yield handler.get_event(auth_user, event_id)
 
+        time_now = self.clock.time_msec()
         if event:
-            defer.returnValue((200, self.hs.serialize_event(event)))
+            defer.returnValue((200, serialize_event(event, time_now)))
         else:
             defer.returnValue((404, "Event not found."))