mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2024-12-12 03:04:19 -05:00
Put room state in room initialSync output - I guess this is right; I really can't find any other tests similar...
This commit is contained in:
parent
269f80bf8e
commit
1fd8139138
@ -336,10 +336,13 @@ class MessageHandler(BaseHandler):
|
|||||||
feedback=False):
|
feedback=False):
|
||||||
yield self.auth.check_joined_room(room_id, user_id)
|
yield self.auth.check_joined_room(room_id, user_id)
|
||||||
|
|
||||||
|
state_tuples = yield self.store.get_current_state(room_id)
|
||||||
|
state = [self.hs.serialize_event(x) for x in state_tuples]
|
||||||
|
|
||||||
defer.returnValue({
|
defer.returnValue({
|
||||||
#"membership": membership,
|
#"membership": membership,
|
||||||
"room_id": room_id,
|
"room_id": room_id,
|
||||||
#"messages": messages,
|
#"messages": messages,
|
||||||
#"state": state,
|
"state": state,
|
||||||
#"presence": presence,
|
#"presence": presence
|
||||||
})
|
})
|
||||||
|
@ -984,6 +984,29 @@ class RoomInitialSyncTestCase(RestTestCase):
|
|||||||
|
|
||||||
synapse.rest.room.register_servlets(hs, self.mock_resource)
|
synapse.rest.room.register_servlets(hs, self.mock_resource)
|
||||||
|
|
||||||
|
# MemoryDataStore's get_current_state() isn't even approximately
|
||||||
|
# right. Longterm we'll be killing it in favour of a real
|
||||||
|
# SQLite :memory:-based test. For now lets patch it
|
||||||
|
efact = hs.get_event_factory()
|
||||||
|
def get_current_state(room_id):
|
||||||
|
"""
|
||||||
|
TODO: these probably need content
|
||||||
|
('!WxMBxqtWbMMdMEkRqY:red', 'm.room.send_event_level', ''),
|
||||||
|
('!WxMBxqtWbMMdMEkRqY:red', 'm.room.power_levels', ''),
|
||||||
|
('!WxMBxqtWbMMdMEkRqY:red', 'm.room.ops_levels', ''),
|
||||||
|
('!WxMBxqtWbMMdMEkRqY:red', 'm.room.member', '@sid1:red'),
|
||||||
|
('!WxMBxqtWbMMdMEkRqY:red', 'm.room.add_state_level', '')]
|
||||||
|
"""
|
||||||
|
return [
|
||||||
|
efact.create_event(etype="m.room.create", room_id=room_id,
|
||||||
|
content={},
|
||||||
|
),
|
||||||
|
efact.create_event(etype="m.room.join_rules", room_id=room_id,
|
||||||
|
content={},
|
||||||
|
),
|
||||||
|
]
|
||||||
|
hs.datastore.get_current_state = get_current_state
|
||||||
|
|
||||||
# create the room
|
# create the room
|
||||||
self.room_id = yield self.create_room_as(self.user_id)
|
self.room_id = yield self.create_room_as(self.user_id)
|
||||||
|
|
||||||
@ -995,6 +1018,18 @@ class RoomInitialSyncTestCase(RestTestCase):
|
|||||||
|
|
||||||
self.assertEquals(self.room_id, response["room_id"])
|
self.assertEquals(self.room_id, response["room_id"])
|
||||||
|
|
||||||
|
# Room state is easier to assert on if we unpack it into a dict
|
||||||
|
state = {}
|
||||||
|
for event in response["state"]:
|
||||||
|
if "state_key" not in event:
|
||||||
|
continue
|
||||||
|
t = event["type"]
|
||||||
|
if t not in state:
|
||||||
|
state[t] = []
|
||||||
|
state[t].append(event)
|
||||||
|
|
||||||
|
self.assertTrue("m.room.create" in state)
|
||||||
|
|
||||||
# (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)
|
||||||
|
Loading…
Reference in New Issue
Block a user