summary refs log tree commit diff
diff options
context:
space:
mode:
authorPaul "LeoNerd" Evans <paul@matrix.org>2014-11-18 14:07:51 +0000
committerPaul "LeoNerd" Evans <paul@matrix.org>2014-11-18 14:07:51 +0000
commit17f977a9de458e375a8e09f8f68ec4393e0dd1bb (patch)
tree7a162402786da071fe5521a18ac1671bad0ce370
parentMerge branch 'develop' into room-initial-sync (diff)
downloadsynapse-17f977a9de458e375a8e09f8f68ec4393e0dd1bb.tar.xz
Include 'messages' snapshot in room initialSync
-rw-r--r--synapse/handlers/message.py21
-rw-r--r--tests/rest/test_rooms.py4
2 files changed, 24 insertions, 1 deletions
diff --git a/synapse/handlers/message.py b/synapse/handlers/message.py
index b77d9d1644..778cdb2317 100644
--- a/synapse/handlers/message.py
+++ b/synapse/handlers/message.py
@@ -308,10 +308,29 @@ class MessageHandler(BaseHandler):
             room_id=room_id
         ))
 
+        now_token = yield self.hs.get_event_sources().get_current_token()
+
+        limit = pagin_config.limit if pagin_config else None
+        if limit is None:
+            limit = 10
+
+        messages, token = yield self.store.get_recent_events_for_room(
+            room_id,
+            limit=limit,
+            end_token=now_token.room_key,
+        )
+
+        start_token = now_token.copy_and_replace("room_key", token[0])
+        end_token = now_token.copy_and_replace("room_key", token[1])
+
         defer.returnValue({
             "membership": member_event.membership,
             "room_id": room_id,
-            #"messages": messages,
+            "messages": {
+                "chunk": [self.hs.serialize_event(m) for m in messages],
+                "start": start_token.to_string(),
+                "end": end_token.to_string(),
+            },
             "state": state,
             #"presence": presence
         })
diff --git a/tests/rest/test_rooms.py b/tests/rest/test_rooms.py
index 98c6af97b0..b7d9a2bd06 100644
--- a/tests/rest/test_rooms.py
+++ b/tests/rest/test_rooms.py
@@ -1050,6 +1050,10 @@ class RoomInitialSyncTestCase(RestTestCase):
 
         self.assertTrue("m.room.create" in state)
 
+        self.assertTrue("messages" in response)
+        self.assertTrue("chunk" in response["messages"])
+        self.assertTrue("end" in response["messages"])
+
 #        (code, response) = yield self.mock_resource.trigger("GET", path, None)
 #        self.assertEquals(200, code, msg=str(response))
 #        self.assert_dict(json.loads(content), response)