summary refs log tree commit diff
path: root/synapse/handlers
diff options
context:
space:
mode:
Diffstat (limited to 'synapse/handlers')
-rw-r--r--synapse/handlers/__init__.py3
-rw-r--r--synapse/handlers/events.py26
-rw-r--r--synapse/handlers/room.py6
3 files changed, 33 insertions, 2 deletions
diff --git a/synapse/handlers/__init__.py b/synapse/handlers/__init__.py
index 8a4aa6e5d6..7417a02cea 100644
--- a/synapse/handlers/__init__.py
+++ b/synapse/handlers/__init__.py
@@ -17,7 +17,7 @@ from .register import RegistrationHandler
 from .room import (
     MessageHandler, RoomCreationHandler, RoomMemberHandler, RoomListHandler
 )
-from .events import EventStreamHandler
+from .events import EventStreamHandler, EventHandler
 from .federation import FederationHandler
 from .login import LoginHandler
 from .profile import ProfileHandler
@@ -39,6 +39,7 @@ class Handlers(object):
         self.room_creation_handler = RoomCreationHandler(hs)
         self.room_member_handler = RoomMemberHandler(hs)
         self.event_stream_handler = EventStreamHandler(hs)
+        self.event_handler = EventHandler(hs)
         self.federation_handler = FederationHandler(hs)
         self.profile_handler = ProfileHandler(hs)
         self.presence_handler = PresenceHandler(hs)
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)
diff --git a/synapse/handlers/room.py b/synapse/handlers/room.py
index 6abfa00c5c..9b02ce0dfd 100644
--- a/synapse/handlers/room.py
+++ b/synapse/handlers/room.py
@@ -249,6 +249,10 @@ class MessageHandler(BaseRoomHandler):
         # FIXME (erikj): We need to not generate this token,
         now_token = "%s_%s" % (now_rooms_token, now_presence_token)
 
+        limit = pagin_config.limit
+        if not limit:
+            limit = 10
+
         for event in room_list:
             d = {
                 "room_id": event.room_id,
@@ -265,7 +269,7 @@ class MessageHandler(BaseRoomHandler):
             try:
                 messages, token = yield self.store.get_recent_events_for_room(
                     event.room_id,
-                    limit=10,
+                    limit=limit,
                     end_token=now_rooms_token,
                 )