summary refs log tree commit diff
path: root/synapse/rest/client
diff options
context:
space:
mode:
authorMark Haines <mark.haines@matrix.org>2015-10-07 15:55:20 +0100
committerMark Haines <mark.haines@matrix.org>2015-10-07 15:55:20 +0100
commite3d3205cd953342ce84b8a148c4f469ce7b79b7a (patch)
tree4996322889142617ab2ab45842a67d154fadc6cf /synapse/rest/client
parentMove the rooms out into a room_map mapping from room_id to room. (diff)
downloadsynapse-e3d3205cd953342ce84b8a148c4f469ce7b79b7a.tar.xz
Update the sync response to match the latest spec
Diffstat (limited to 'synapse/rest/client')
-rw-r--r--synapse/rest/client/v2_alpha/sync.py46
1 files changed, 22 insertions, 24 deletions
diff --git a/synapse/rest/client/v2_alpha/sync.py b/synapse/rest/client/v2_alpha/sync.py
index 1f3824d924..84011918af 100644
--- a/synapse/rest/client/v2_alpha/sync.py
+++ b/synapse/rest/client/v2_alpha/sync.py
@@ -45,26 +45,29 @@ class SyncRestServlet(RestServlet):
         {
           "next_batch": // batch token for the next /sync
           "presence": // presence data for the user.
-          "rooms": {
-            "default": {
                "invited": [], // Ids of invited rooms being updated.
                "joined": [], // Ids of joined rooms being updated.
                "archived": [] // Ids of archived rooms being updated.
             }
           }
-          "room_map": {
-            "${room_id}": { // Id of the room being updated
-              "event_map": // Map of EventID -> event JSON.
-              "timeline": { // The recent events in the room if gap is "true"
+          "rooms": {
+            "joined": { // Joined rooms being updated.
+              "${room_id}": { // Id of the room being updated
+                "event_map": // Map of EventID -> event JSON.
+                "timeline": { // The recent events in the room if gap is "true"
                   "limited": // Was the per-room event limit exceeded?
-                          // otherwise the next events in the room.
-                  "batch": [] // list of EventIDs in the "event_map".
+                             // otherwise the next events in the room.
+                  "events": [] // list of EventIDs in the "event_map".
                   "prev_batch": // back token for getting previous events.
+                }
+                "state": {"events": []} // list of EventIDs updating the
+                                        // current state to be what it should
+                                        // be at the end of the batch.
+                "ephemeral": {"events": []} // list of event objects
               }
-              "state": [] // list of EventIDs updating the current state to
-                          // be what it should be at the end of the batch.
-              "ephemeral": []
-            }
+            },
+            "invited": {}, // Ids of invited rooms being updated.
+            "archived": {} // Ids of archived rooms being updated.
           }
         }
     """
@@ -121,7 +124,7 @@ class SyncRestServlet(RestServlet):
 
         time_now = self.clock.time_msec()
 
-        room_map, rooms = self.encode_rooms(
+        rooms = self.encode_rooms(
             sync_result.rooms, filter, time_now, token_id
         )
 
@@ -129,7 +132,6 @@ class SyncRestServlet(RestServlet):
             "presence": self.encode_user_data(
                 sync_result.presence, filter, time_now
             ),
-            "room_map": room_map,
             "rooms": rooms,
             "next_batch": sync_result.next_batch.to_string(),
         }
@@ -140,20 +142,16 @@ class SyncRestServlet(RestServlet):
         return events
 
     def encode_rooms(self, rooms, filter, time_now, token_id):
-        room_map = {}
-        joined = []
+        joined = {}
         for room in rooms:
-            room_map[room.room_id] = self.encode_room(
+            joined[room.room_id] = self.encode_room(
                 room, filter, time_now, token_id
             )
-            joined.append(room.room_id)
 
-        return room_map, {
-            "default": {
-                "joined": joined,
-                "invited": [],
-                "archived": [],
-            }
+        return {
+            "joined": joined,
+            "invited": {},
+            "archived": {},
         }
 
     @staticmethod