From 20239b5cb7455d593680b17d2d80d2a4850c524d Mon Sep 17 00:00:00 2001 From: Andrew Godwin Date: Sun, 11 Dec 2022 12:37:28 -0700 Subject: Basic post mutation --- api/views/notifications.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'api/views/notifications.py') diff --git a/api/views/notifications.py b/api/views/notifications.py index 9ccda81..7b05d14 100644 --- a/api/views/notifications.py +++ b/api/views/notifications.py @@ -1,8 +1,7 @@ -from activities.models import TimelineEvent - -from .. import schemas -from ..decorators import identity_required -from .base import api_router +from activities.models import PostInteraction, TimelineEvent +from api import schemas +from api.decorators import identity_required +from api.views.base import api_router @api_router.get("/v1/notifications", response=list[schemas.Notification]) @@ -49,4 +48,9 @@ def notifications( # invert the ordering to accomodate anchor_event = TimelineEvent.objects.get(pk=min_id) events = events.filter(created__gt=anchor_event.created).order_by("created") - return [event.to_mastodon_notification_json() for event in events[:limit]] + events = list(events[:limit]) + interactions = PostInteraction.get_event_interactions(events, request.identity) + return [ + event.to_mastodon_notification_json(interactions=interactions) + for event in events + ] -- cgit v1.2.3