diff options
author | Richard van der Hoff <github@rvanderhoff.org.uk> | 2018-01-11 14:47:18 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-11 14:47:18 +0000 |
commit | 5f23b6d5ead26184a565e0c4f499d60b0f7e9a6f (patch) | |
tree | 5bcba1460ab4faca2668a5af5c9d5094589a6882 /synapse/rest/client | |
parent | Merge branch 'master' of github.com:matrix-org/synapse into develop (diff) | |
parent | Add /room/{id}/event/{id} to synapse (diff) | |
download | synapse-5f23b6d5ead26184a565e0c4f499d60b0f7e9a6f.tar.xz |
Merge pull request #2766 from matrix-org/rav/room_event
Add /room/{id}/event/{id} to synapse
Diffstat (limited to 'synapse/rest/client')
-rw-r--r-- | synapse/rest/client/v1/room.py | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/synapse/rest/client/v1/room.py b/synapse/rest/client/v1/room.py index 75b735b47d..682a0af9fc 100644 --- a/synapse/rest/client/v1/room.py +++ b/synapse/rest/client/v1/room.py @@ -487,13 +487,35 @@ class RoomInitialSyncRestServlet(ClientV1RestServlet): defer.returnValue((200, content)) -class RoomEventContext(ClientV1RestServlet): +class RoomEventServlet(ClientV1RestServlet): + PATTERNS = client_path_patterns( + "/rooms/(?P<room_id>[^/]*)/event/(?P<event_id>[^/]*)$" + ) + + def __init__(self, hs): + super(RoomEventServlet, self).__init__(hs) + self.clock = hs.get_clock() + self.event_handler = hs.get_event_handler() + + @defer.inlineCallbacks + def on_GET(self, request, room_id, event_id): + requester = yield self.auth.get_user_by_req(request) + event = yield self.event_handler.get_event(requester.user, event_id) + + time_now = self.clock.time_msec() + if event: + defer.returnValue((200, serialize_event(event, time_now))) + else: + defer.returnValue((404, "Event not found.")) + + +class RoomEventContextServlet(ClientV1RestServlet): PATTERNS = client_path_patterns( "/rooms/(?P<room_id>[^/]*)/context/(?P<event_id>[^/]*)$" ) def __init__(self, hs): - super(RoomEventContext, self).__init__(hs) + super(RoomEventContextServlet, self).__init__(hs) self.clock = hs.get_clock() self.handlers = hs.get_handlers() @@ -803,4 +825,5 @@ def register_servlets(hs, http_server): RoomTypingRestServlet(hs).register(http_server) SearchRestServlet(hs).register(http_server) JoinedRoomsRestServlet(hs).register(http_server) - RoomEventContext(hs).register(http_server) + RoomEventServlet(hs).register(http_server) + RoomEventContextServlet(hs).register(http_server) |