summary refs log tree commit diff
path: root/synapse/rest/room.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2014-08-19 14:20:03 +0100
committerErik Johnston <erik@matrix.org>2014-08-19 14:20:03 +0100
commit75b6d982a01a431a89d2ab76d91a09159630d059 (patch)
treefbcaf076fba353d05f757180ab19f7ea823c37e4 /synapse/rest/room.py
parentChange the way pagination works to support out of order events. (diff)
downloadsynapse-75b6d982a01a431a89d2ab76d91a09159630d059.tar.xz
Add a 'backfill room' button
Diffstat (limited to 'synapse/rest/room.py')
-rw-r--r--synapse/rest/room.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/synapse/rest/room.py b/synapse/rest/room.py
index dfb2aabe70..89ea9f0d25 100644
--- a/synapse/rest/room.py
+++ b/synapse/rest/room.py
@@ -383,6 +383,21 @@ class RoomMessageListRestServlet(RestServlet):
         defer.returnValue((200, msgs))
 
 
+class RoomTriggerBackfill(RestServlet):
+    PATTERN = client_path_pattern("/rooms/(?P<room_id>[^/]*)/backfill$")
+
+    @defer.inlineCallbacks
+    def on_GET(self, request, room_id):
+        remote_server = urllib.unquote(request.args["remote"][0])
+        room_id = urllib.unquote(room_id)
+        limit = int(request.args["limit"][0])
+
+        handler = self.handlers.federation_handler
+        events = yield handler.backfill(remote_server, room_id, limit)
+
+        res = [event.get_dict() for event in events]
+        defer.returnValue((200, res))
+
 def _parse_json(request):
     try:
         content = json.loads(request.content.read())
@@ -403,3 +418,4 @@ def register_servlets(hs, http_server):
     RoomMemberListRestServlet(hs).register(http_server)
     RoomMessageListRestServlet(hs).register(http_server)
     JoinRoomAliasServlet(hs).register(http_server)
+    RoomTriggerBackfill(hs).register(http_server)