Update the sync response to match the latest spec

pull/305/head
Mark Haines 2015-10-07 15:55:20 +01:00
parent 471555b3a8
commit e3d3205cd9
1 changed files with 22 additions and 24 deletions

View File

@ -45,26 +45,29 @@ class SyncRestServlet(RestServlet):
{ {
"next_batch": // batch token for the next /sync "next_batch": // batch token for the next /sync
"presence": // presence data for the user. "presence": // presence data for the user.
"rooms": {
"default": {
"invited": [], // Ids of invited rooms being updated. "invited": [], // Ids of invited rooms being updated.
"joined": [], // Ids of joined rooms being updated. "joined": [], // Ids of joined rooms being updated.
"archived": [] // Ids of archived rooms being updated. "archived": [] // Ids of archived rooms being updated.
} }
} }
"room_map": { "rooms": {
"joined": { // Joined rooms being updated.
"${room_id}": { // Id of the room being updated "${room_id}": { // Id of the room being updated
"event_map": // Map of EventID -> event JSON. "event_map": // Map of EventID -> event JSON.
"timeline": { // The recent events in the room if gap is "true" "timeline": { // The recent events in the room if gap is "true"
"limited": // Was the per-room event limit exceeded? "limited": // Was the per-room event limit exceeded?
// otherwise the next events in the room. // otherwise the next events in the room.
"batch": [] // list of EventIDs in the "event_map". "events": [] // list of EventIDs in the "event_map".
"prev_batch": // back token for getting previous events. "prev_batch": // back token for getting previous events.
} }
"state": [] // list of EventIDs updating the current state to "state": {"events": []} // list of EventIDs updating the
// be what it should be at the end of the batch. // current state to be what it should
"ephemeral": [] // be at the end of the batch.
"ephemeral": {"events": []} // list of event objects
} }
},
"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() time_now = self.clock.time_msec()
room_map, rooms = self.encode_rooms( rooms = self.encode_rooms(
sync_result.rooms, filter, time_now, token_id sync_result.rooms, filter, time_now, token_id
) )
@ -129,7 +132,6 @@ class SyncRestServlet(RestServlet):
"presence": self.encode_user_data( "presence": self.encode_user_data(
sync_result.presence, filter, time_now sync_result.presence, filter, time_now
), ),
"room_map": room_map,
"rooms": rooms, "rooms": rooms,
"next_batch": sync_result.next_batch.to_string(), "next_batch": sync_result.next_batch.to_string(),
} }
@ -140,20 +142,16 @@ class SyncRestServlet(RestServlet):
return events return events
def encode_rooms(self, rooms, filter, time_now, token_id): def encode_rooms(self, rooms, filter, time_now, token_id):
room_map = {} joined = {}
joined = []
for room in rooms: 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 room, filter, time_now, token_id
) )
joined.append(room.room_id)
return room_map, { return {
"default": {
"joined": joined, "joined": joined,
"invited": [], "invited": {},
"archived": [], "archived": {},
}
} }
@staticmethod @staticmethod