From e98b033646b0d9d7851d2a0e736ff6f1b60b0ef8 Mon Sep 17 00:00:00 2001 From: Aljoscha Rittner Date: Fri, 24 Jun 2022 17:23:00 +0200 Subject: Preserves storage of pagination in items for compatibility reason fixes #232 --- mastodon/Mastodon.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'mastodon') 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: del next_params['min_id'] response._pagination_next = next_params + # Maybe other API users rely on the pagination info in the last item + # Will be removed in future + if isinstance(response[-1], AttribAccessDict): + response[-1]._pagination_next = next_params + if url['rel'] == 'prev': # Be paranoid and extract since_id or min_id specifically prev_url = url['url'] @@ -3515,7 +3520,12 @@ class Mastodon: if "max_id" in prev_params: del prev_params['max_id'] response._pagination_prev = prev_params - + + # Maybe other API users rely on the pagination info in the first item + # Will be removed in future + if isinstance(response[0], AttribAccessDict): + response[0]._pagination_prev = prev_params + # New and fantastico (post-2.6.0): min_id pagination matchgroups = re.search(r"[?&]min_id=([^&]+)", prev_url) if matchgroups: @@ -3531,6 +3541,11 @@ class Mastodon: del prev_params['max_id'] response._pagination_prev = prev_params + # Maybe other API users rely on the pagination info in the first item + # Will be removed in future + if isinstance(response[0], AttribAccessDict): + response[0]._pagination_prev = prev_params + return response def __get_streaming_base(self): -- cgit v1.2.3