Have room initialSync return the room's room_id

This commit is contained in:
Paul "LeoNerd" Evans 2014-11-10 19:02:19 +00:00
parent 50c8e3fcda
commit 269f80bf8e
3 changed files with 19 additions and 21 deletions

View File

@ -331,4 +331,15 @@ class MessageHandler(BaseHandler):
defer.returnValue(ret) defer.returnValue(ret)
@defer.inlineCallbacks
def snapshot_room(self, user_id, room_id, pagin_config=None,
feedback=False):
yield self.auth.check_joined_room(room_id, user_id)
defer.returnValue({
#"membership": membership,
"room_id": room_id,
#"messages": messages,
#"state": state,
#"presence": presence,
})

View File

@ -353,27 +353,12 @@ class RoomInitialSyncRestServlet(RestServlet):
@defer.inlineCallbacks @defer.inlineCallbacks
def on_GET(self, request, room_id): def on_GET(self, request, room_id):
yield self.auth.get_user_by_req(request) user = yield self.auth.get_user_by_req(request)
# TODO: Get all the initial sync data for this room and return in the events = yield self.handlers.message_handler.snapshot_room(
# same format as initial sync, that is: room_id=room_id,
# { user_id=user.to_string(),
# membership: join, )
# messages: [ defer.returnValue((200, events))
# chunk: [ msg events ],
# start: s_tok,
# end: e_tok
# ],
# room_id: foo,
# state: [
# { state event } , { state event }
# ]
# }
# Probably worth keeping the keys room_id and membership for parity
# with /initialSync even though they must be joined to sync this and
# know the room ID, so clients can reuse the same code (room_id and
# membership are MANDATORY for /initialSync, so the code will expect
# it to be there)
defer.returnValue((200, {}))
class RoomTriggerBackfill(RestServlet): class RoomTriggerBackfill(RestServlet):

View File

@ -993,6 +993,8 @@ class RoomInitialSyncTestCase(RestTestCase):
"/rooms/%s/initialSync" % self.room_id) "/rooms/%s/initialSync" % self.room_id)
self.assertEquals(200, code) self.assertEquals(200, code)
self.assertEquals(self.room_id, response["room_id"])
# (code, response) = yield self.mock_resource.trigger("GET", path, None) # (code, response) = yield self.mock_resource.trigger("GET", path, None)
# self.assertEquals(200, code, msg=str(response)) # self.assertEquals(200, code, msg=str(response))
# self.assert_dict(json.loads(content), response) # self.assert_dict(json.loads(content), response)