diff options
author | Andrew Godwin | 2022-12-11 13:37:58 -0700 |
---|---|---|
committer | Andrew Godwin | 2022-12-12 11:56:49 -0700 |
commit | d5a6cbedd3e056e8b9761829d5df46395a9555e1 (patch) | |
tree | 085ad68e1875ed2d26b4ddd71f20dad3d3703398 /api | |
parent | 20239b5cb7455d593680b17d2d80d2a4850c524d (diff) | |
download | takahe-d5a6cbedd3e056e8b9761829d5df46395a9555e1.tar.gz takahe-d5a6cbedd3e056e8b9761829d5df46395a9555e1.tar.bz2 takahe-d5a6cbedd3e056e8b9761829d5df46395a9555e1.zip |
Fix notification pagination
Diffstat (limited to 'api')
-rw-r--r-- | api/views/notifications.py | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/api/views/notifications.py b/api/views/notifications.py index 7b05d14..9f1f865 100644 --- a/api/views/notifications.py +++ b/api/views/notifications.py @@ -1,4 +1,4 @@ -from activities.models import PostInteraction, TimelineEvent +from activities.models import Post, PostInteraction, TimelineEvent from api import schemas from api.decorators import identity_required from api.views.base import api_router @@ -38,16 +38,16 @@ def notifications( .select_related("subject_post", "subject_post__author", "subject_identity") ) if max_id: - anchor_event = TimelineEvent.objects.get(pk=max_id) - events = events.filter(created__lt=anchor_event.created) + anchor_post = Post.objects.get(pk=max_id) + events = events.filter(created__lt=anchor_post.created) if since_id: - anchor_event = TimelineEvent.objects.get(pk=since_id) - events = events.filter(created__gt=anchor_event.created) + anchor_post = Post.objects.get(pk=since_id) + events = events.filter(created__gt=anchor_post.created) if min_id: # Min ID requires LIMIT events _immediately_ newer than specified, so we # invert the ordering to accomodate - anchor_event = TimelineEvent.objects.get(pk=min_id) - events = events.filter(created__gt=anchor_event.created).order_by("created") + anchor_post = Post.objects.get(pk=min_id) + events = events.filter(created__gt=anchor_post.created).order_by("created") events = list(events[:limit]) interactions = PostInteraction.get_event_interactions(events, request.identity) return [ |