diff options
author | Aljoscha Rittner <[email protected]> | 2022-06-24 17:23:00 +0200 |
---|---|---|
committer | Aljoscha Rittner <[email protected]> | 2022-06-24 17:23:00 +0200 |
commit | e98b033646b0d9d7851d2a0e736ff6f1b60b0ef8 (patch) | |
tree | d1e450afcca6760d53d340359be6cbc26e35137d /mastodon | |
parent | 7e0460ddcb9b229a9b899913fab04055d5042cfd (diff) | |
download | mastodon.py-e98b033646b0d9d7851d2a0e736ff6f1b60b0ef8.tar.gz |
Preserves storage of pagination in items for compatibility reason
fixes #232
Diffstat (limited to 'mastodon')
-rw-r--r-- | mastodon/Mastodon.py | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/mastodon/Mastodon.py b/mastodon/Mastodon.py index 0304b8f..0922a6f 100644 --- a/mastodon/Mastodon.py +++ b/mastodon/Mastodon.py | |||
@@ -3497,6 +3497,11 @@ class Mastodon: | |||
3497 | del next_params['min_id'] | 3497 | del next_params['min_id'] |
3498 | response._pagination_next = next_params | 3498 | response._pagination_next = next_params |
3499 | 3499 | ||
3500 | # Maybe other API users rely on the pagination info in the last item | ||
3501 | # Will be removed in future | ||
3502 | if isinstance(response[-1], AttribAccessDict): | ||
3503 | response[-1]._pagination_next = next_params | ||
3504 | |||
3500 | if url['rel'] == 'prev': | 3505 | if url['rel'] == 'prev': |
3501 | # Be paranoid and extract since_id or min_id specifically | 3506 | # Be paranoid and extract since_id or min_id specifically |
3502 | prev_url = url['url'] | 3507 | prev_url = url['url'] |
@@ -3515,7 +3520,12 @@ class Mastodon: | |||
3515 | if "max_id" in prev_params: | 3520 | if "max_id" in prev_params: |
3516 | del prev_params['max_id'] | 3521 | del prev_params['max_id'] |
3517 | response._pagination_prev = prev_params | 3522 | response._pagination_prev = prev_params |
3518 | 3523 | ||
3524 | # Maybe other API users rely on the pagination info in the first item | ||
3525 | # Will be removed in future | ||
3526 | if isinstance(response[0], AttribAccessDict): | ||
3527 | response[0]._pagination_prev = prev_params | ||
3528 | |||
3519 | # New and fantastico (post-2.6.0): min_id pagination | 3529 | # New and fantastico (post-2.6.0): min_id pagination |
3520 | matchgroups = re.search(r"[?&]min_id=([^&]+)", prev_url) | 3530 | matchgroups = re.search(r"[?&]min_id=([^&]+)", prev_url) |
3521 | if matchgroups: | 3531 | if matchgroups: |
@@ -3531,6 +3541,11 @@ class Mastodon: | |||
3531 | del prev_params['max_id'] | 3541 | del prev_params['max_id'] |
3532 | response._pagination_prev = prev_params | 3542 | response._pagination_prev = prev_params |
3533 | 3543 | ||
3544 | # Maybe other API users rely on the pagination info in the first item | ||
3545 | # Will be removed in future | ||
3546 | if isinstance(response[0], AttribAccessDict): | ||
3547 | response[0]._pagination_prev = prev_params | ||
3548 | |||
3534 | return response | 3549 | return response |
3535 | 3550 | ||
3536 | def __get_streaming_base(self): | 3551 | def __get_streaming_base(self): |