Update the pagination parameter name based on MSC2946 review. (#10579)
parent
915b37e5ef
commit
98a3355d9a
|
@ -0,0 +1 @@
|
||||||
|
Add pagination to the spaces summary based on updates to [MSC2946](https://github.com/matrix-org/matrix-doc/pull/2946).
|
|
@ -412,10 +412,10 @@ class SpaceSummaryHandler:
|
||||||
|
|
||||||
# If there's additional data, generate a pagination token (and persist state).
|
# If there's additional data, generate a pagination token (and persist state).
|
||||||
if room_queue:
|
if room_queue:
|
||||||
next_token = random_string(24)
|
next_batch = random_string(24)
|
||||||
result["next_token"] = next_token
|
result["next_batch"] = next_batch
|
||||||
pagination_key = _PaginationKey(
|
pagination_key = _PaginationKey(
|
||||||
requested_room_id, suggested_only, max_depth, next_token
|
requested_room_id, suggested_only, max_depth, next_batch
|
||||||
)
|
)
|
||||||
self._pagination_sessions[pagination_key] = _PaginationSession(
|
self._pagination_sessions[pagination_key] = _PaginationSession(
|
||||||
self._clock.time_msec(), room_queue, processed_rooms
|
self._clock.time_msec(), room_queue, processed_rooms
|
||||||
|
|
|
@ -466,19 +466,19 @@ class SpaceSummaryTestCase(unittest.HomeserverTestCase):
|
||||||
expected: List[Tuple[str, Iterable[str]]] = [(self.space, room_ids)]
|
expected: List[Tuple[str, Iterable[str]]] = [(self.space, room_ids)]
|
||||||
expected += [(room_id, ()) for room_id in room_ids[:6]]
|
expected += [(room_id, ()) for room_id in room_ids[:6]]
|
||||||
self._assert_hierarchy(result, expected)
|
self._assert_hierarchy(result, expected)
|
||||||
self.assertIn("next_token", result)
|
self.assertIn("next_batch", result)
|
||||||
|
|
||||||
# Check the next page.
|
# Check the next page.
|
||||||
result = self.get_success(
|
result = self.get_success(
|
||||||
self.handler.get_room_hierarchy(
|
self.handler.get_room_hierarchy(
|
||||||
self.user, self.space, limit=5, from_token=result["next_token"]
|
self.user, self.space, limit=5, from_token=result["next_batch"]
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
# The result should have the space and the room in it, along with a link
|
# The result should have the space and the room in it, along with a link
|
||||||
# from space -> room.
|
# from space -> room.
|
||||||
expected = [(room_id, ()) for room_id in room_ids[6:]]
|
expected = [(room_id, ()) for room_id in room_ids[6:]]
|
||||||
self._assert_hierarchy(result, expected)
|
self._assert_hierarchy(result, expected)
|
||||||
self.assertNotIn("next_token", result)
|
self.assertNotIn("next_batch", result)
|
||||||
|
|
||||||
def test_invalid_pagination_token(self):
|
def test_invalid_pagination_token(self):
|
||||||
""""""
|
""""""
|
||||||
|
@ -493,12 +493,12 @@ class SpaceSummaryTestCase(unittest.HomeserverTestCase):
|
||||||
result = self.get_success(
|
result = self.get_success(
|
||||||
self.handler.get_room_hierarchy(self.user, self.space, limit=7)
|
self.handler.get_room_hierarchy(self.user, self.space, limit=7)
|
||||||
)
|
)
|
||||||
self.assertIn("next_token", result)
|
self.assertIn("next_batch", result)
|
||||||
|
|
||||||
# Changing the room ID, suggested-only, or max-depth causes an error.
|
# Changing the room ID, suggested-only, or max-depth causes an error.
|
||||||
self.get_failure(
|
self.get_failure(
|
||||||
self.handler.get_room_hierarchy(
|
self.handler.get_room_hierarchy(
|
||||||
self.user, self.room, from_token=result["next_token"]
|
self.user, self.room, from_token=result["next_batch"]
|
||||||
),
|
),
|
||||||
SynapseError,
|
SynapseError,
|
||||||
)
|
)
|
||||||
|
@ -507,13 +507,13 @@ class SpaceSummaryTestCase(unittest.HomeserverTestCase):
|
||||||
self.user,
|
self.user,
|
||||||
self.space,
|
self.space,
|
||||||
suggested_only=True,
|
suggested_only=True,
|
||||||
from_token=result["next_token"],
|
from_token=result["next_batch"],
|
||||||
),
|
),
|
||||||
SynapseError,
|
SynapseError,
|
||||||
)
|
)
|
||||||
self.get_failure(
|
self.get_failure(
|
||||||
self.handler.get_room_hierarchy(
|
self.handler.get_room_hierarchy(
|
||||||
self.user, self.space, max_depth=0, from_token=result["next_token"]
|
self.user, self.space, max_depth=0, from_token=result["next_batch"]
|
||||||
),
|
),
|
||||||
SynapseError,
|
SynapseError,
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue