Support spaces with > 50 rooms in the /hierarchy endpoint. (#11695)

By returning all of the m.space.child state of the space, not just
the first 50. The number of rooms returned is still capped at 50.

For the federation API this implies that the requesting server will
need to individually query for any other rooms it is not joined to.
This commit is contained in:
Patrick Cloke 2022-01-07 19:27:58 -05:00 committed by GitHub
parent d3cf0730f8
commit 8e57584a58
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 55 additions and 8 deletions

View file

@ -253,6 +253,38 @@ class SpaceSummaryTestCase(unittest.HomeserverTestCase):
)
self._assert_hierarchy(result, expected)
def test_large_space(self):
"""Test a space with a large number of rooms."""
rooms = [self.room]
# Make at least 51 rooms that are part of the space.
for _ in range(55):
room = self.helper.create_room_as(self.user, tok=self.token)
self._add_child(self.space, room, self.token)
rooms.append(room)
result = self.get_success(self.handler.get_space_summary(self.user, self.space))
# The spaces result should have the space and the first 50 rooms in it,
# along with the links from space -> room for those 50 rooms.
expected = [(self.space, rooms[:50])] + [(room, []) for room in rooms[:49]]
self._assert_rooms(result, expected)
# The result should have the space and the rooms in it, along with the links
# from space -> room.
expected = [(self.space, rooms)] + [(room, []) for room in rooms]
# Make two requests to fully paginate the results.
result = self.get_success(
self.handler.get_room_hierarchy(create_requester(self.user), self.space)
)
result2 = self.get_success(
self.handler.get_room_hierarchy(
create_requester(self.user), self.space, from_token=result["next_batch"]
)
)
# Combine the results.
result["rooms"] += result2["rooms"]
self._assert_hierarchy(result, expected)
def test_visibility(self):
"""A user not in a space cannot inspect it."""
user2 = self.register_user("user2", "pass")