summary refs log tree commit diff
path: root/synapse/handlers/events.py
diff options
context:
space:
mode:
authorKegan Dougal <kegan@matrix.org>2014-08-27 10:33:01 +0100
committerKegan Dougal <kegan@matrix.org>2014-08-27 10:33:01 +0100
commitc65885e1668d4a241a04a7cb3b970a0d6833a5ad (patch)
tree10e823a6b6dccc7770be0de5de1922e09695a1eb /synapse/handlers/events.py
parentModified /join/$identifier to support $identifier being a room ID in addition... (diff)
downloadsynapse-c65885e1668d4a241a04a7cb3b970a0d6833a5ad.tar.xz
Added support for GET /events/$eventid with auth checks.
Diffstat (limited to 'synapse/handlers/events.py')
-rw-r--r--synapse/handlers/events.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/synapse/handlers/events.py b/synapse/handlers/events.py
index 6bb797caf2..1bd173acd8 100644
--- a/synapse/handlers/events.py
+++ b/synapse/handlers/events.py
@@ -144,3 +144,29 @@ class EventStreamHandler(BaseHandler):
                 self._stop_timer_per_user[auth_user] = (
                     self.clock.call_later(5, _later)
                 )
+
+
+class EventHandler(BaseHandler):
+
+    @defer.inlineCallbacks
+    def get_event(self, user, event_id):
+        """Retrieve a single specified event.
+
+        Args:
+            user (synapse.types.UserID): The user requesting the event
+            event_id (str): The event ID to obtain.
+        Returns:
+            dict: An event, or None if there is no event matching this ID.
+        Raises:
+            SynapseError if there was a problem retrieving this event, or
+            AuthError if the user does not have the rights to inspect this
+            event.
+        """
+        event = yield self.store.get_event(event_id)
+
+        if not event:
+            defer.returnValue(None)
+            return
+
+        yield self.auth.check(event, raises=True)
+        defer.returnValue(event)