Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Update the pagination parameter name based on MSC2946 review.
Browse files Browse the repository at this point in the history
  • Loading branch information
clokep committed Aug 11, 2021
1 parent 8c654b7 commit da91136
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
1 change: 1 addition & 0 deletions changelog.d/10579.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add pagination to the spaces summary based on updates to [MSC2946](https://github.com/matrix-org/matrix-doc/pull/2946).
6 changes: 3 additions & 3 deletions synapse/handlers/space_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,10 +385,10 @@ async def _get_room_hierarchy(

# If there's additional data, generate a pagination token (and persist state).
if room_queue:
next_token = random_string(24)
result["next_token"] = next_token
next_batch = random_string(24)
result["next_batch"] = next_batch
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(
room_queue, processed_rooms
Expand Down
14 changes: 7 additions & 7 deletions tests/handlers/test_space_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,19 +443,19 @@ def test_pagination(self):
(room_id, ()) for room_id in room_ids[:6]
]
self._assert_hierarchy(result, expected)
self.assertIn("next_token", result)
self.assertIn("next_batch", result)

# Check the next page.
result = self.get_success(
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
# from space -> room.
expected = [(room_id, ()) for room_id in room_ids[6:]]
self._assert_hierarchy(result, expected)
self.assertNotIn("next_token", result)
self.assertNotIn("next_batch", result)

def test_invalid_pagination_token(self):
""""""
Expand All @@ -470,12 +470,12 @@ def test_invalid_pagination_token(self):
result = self.get_success(
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.
self.get_failure(
self.handler.get_room_hierarchy(
self.user, self.room, from_token=result["next_token"]
self.user, self.room, from_token=result["next_batch"]
),
SynapseError,
)
Expand All @@ -484,13 +484,13 @@ def test_invalid_pagination_token(self):
self.user,
self.space,
suggested_only=True,
from_token=result["next_token"],
from_token=result["next_batch"],
),
SynapseError,
)
self.get_failure(
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,
)
Expand Down

0 comments on commit da91136

Please sign in to comment.