This repository was archived by the owner on Apr 26, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Support pagination tokens from sync/messages in the relations API #11952
Merged
Merged
Changes from 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
b2e0c7a
Use RoomStreamTokens instead of RelationPaginationTokens.
clokep 318f588
Consolidate logic.
clokep f70a71c
Parse received StreamTokens.
clokep 6c18d18
Convert to_dict to async.
clokep 2e1627d
Use and generate StreamTokens.
clokep b6a7409
Add tests for the legacy pagination token format.
clokep ae9b12d
Newsfragment
clokep 62cba89
Fixup comments in tests.
clokep 0557b7a
Clarify comment.
clokep File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -241,6 +241,60 @@ def test_repeated_paginate_relations(self): | |
| found_event_ids.reverse() | ||
| self.assertEquals(found_event_ids, expected_event_ids) | ||
|
|
||
| def test_pagination_from_sync_messages(self): | ||
| """Pagination tokens from sync and messages should work.""" | ||
clokep marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| channel = self._send_relation(RelationTypes.ANNOTATION, "m.reaction", "A") | ||
| self.assertEquals(200, channel.code, channel.json_body) | ||
| annotation_id = channel.json_body["event_id"] | ||
| # Send an event after the relation events. | ||
| self.helper.send(self.room, body="Latest event", tok=self.user_token) | ||
|
|
||
| # Request sync, but limit the timeline to get a pagination token before | ||
| # the reaction. | ||
| filter = urllib.parse.quote_plus( | ||
| '{"room": {"timeline": {"limit": 1}}}'.encode() | ||
| ) | ||
|
||
| channel = self.make_request( | ||
| "GET", f"/sync?filter={filter}", access_token=self.user_token | ||
| ) | ||
| self.assertEquals(200, channel.code, channel.json_body) | ||
| room_timeline = channel.json_body["rooms"]["join"][self.room]["timeline"] | ||
| sync_prev_batch = room_timeline["prev_batch"] | ||
| self.assertIsNotNone(sync_prev_batch) | ||
| # Ensure the event above is not in the batch. | ||
| self.assertNotIn( | ||
| annotation_id, [ev["event_id"] for ev in room_timeline["events"]] | ||
| ) | ||
clokep marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| channel = self.make_request( | ||
clokep marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| "GET", | ||
| f"/rooms/{self.room}/messages?dir=b&limit=1", | ||
| access_token=self.user_token, | ||
| ) | ||
| self.assertEquals(200, channel.code, channel.json_body) | ||
| messages_end = channel.json_body["end"] | ||
| self.assertIsNotNone(messages_end) | ||
| # Ensure the event above is not in the chunk. | ||
clokep marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| self.assertNotIn( | ||
| annotation_id, [ev["event_id"] for ev in channel.json_body["chunk"]] | ||
| ) | ||
|
|
||
| # Request the relations with the token from sync/messages -- this is a | ||
| # tiny bit silly since how do we know the parent ID? Just assume we had | ||
| # it from an earlier sync and the above are gappy. | ||
clokep marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| for from_token in (sync_prev_batch, messages_end): | ||
| channel = self.make_request( | ||
| "GET", | ||
| f"/_matrix/client/unstable/rooms/{self.room}/relations/{self.parent_id}?from={from_token}", | ||
| access_token=self.user_token, | ||
| ) | ||
| self.assertEquals(200, channel.code, channel.json_body) | ||
|
|
||
| # The relation should be in the above. | ||
| self.assertIn( | ||
| annotation_id, [ev["event_id"] for ev in channel.json_body["chunk"]] | ||
| ) | ||
|
|
||
| def test_aggregation_pagination_groups(self): | ||
| """Test that we can paginate annotation groups correctly.""" | ||
|
|
||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.