summary refs log tree commit diff
path: root/synapse/rest/events.py
diff options
context:
space:
mode:
authorMark Haines <mark.haines@matrix.org>2014-08-27 11:19:37 +0100
committerMark Haines <mark.haines@matrix.org>2014-08-27 11:19:37 +0100
commitbf05218c4b1740cdc5477cadbc36f0575e2dcd51 (patch)
treeced8ed09e18afb11e97734959150b8ef7f0db833 /synapse/rest/events.py
parentFold federation/handler into handlers/federation (diff)
parentAdded support for GET /events/$eventid with auth checks. (diff)
downloadsynapse-bf05218c4b1740cdc5477cadbc36f0575e2dcd51.tar.xz
Merge branch 'develop' into storage_transactions
Diffstat (limited to 'synapse/rest/events.py')
-rw-r--r--synapse/rest/events.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/synapse/rest/events.py b/synapse/rest/events.py
index ca2f6978e5..d89dfc193c 100644
--- a/synapse/rest/events.py
+++ b/synapse/rest/events.py
@@ -47,5 +47,22 @@ class EventStreamRestServlet(RestServlet):
         return (200, {})
 
 
+# TODO: Unit test gets, with and without auth, with different kinds of events.
+class EventRestServlet(RestServlet):
+    PATTERN = client_path_pattern("/events/(?P<event_id>[^/]*)$")
+
+    @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)
+
+        if event:
+            defer.returnValue((200, event.get_dict()))
+        else:
+            defer.returnValue((404, "Event not found."))
+
+
 def register_servlets(hs, http_server):
     EventStreamRestServlet(hs).register(http_server)
+    EventRestServlet(hs).register(http_server)