From e34e4c0c77f10413602e2964eaa65ac217d2b103 Mon Sep 17 00:00:00 2001 From: Andrew Godwin Date: Wed, 5 Jul 2023 07:58:54 -0600 Subject: [PATCH] Fixed #599: Interaction state not present on notifications --- api/schemas.py | 3 ++- api/views/notifications.py | 11 +++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/api/schemas.py b/api/schemas.py index 3be6b05..268cdb7 100644 --- a/api/schemas.py +++ b/api/schemas.py @@ -273,8 +273,9 @@ class Notification(Schema): def from_timeline_event( cls, event: activities_models.TimelineEvent, + interactions=None, ) -> "Notification": - return cls(**event.to_mastodon_notification_json()) + return cls(**event.to_mastodon_notification_json(interactions=interactions)) class Tag(Schema): diff --git a/api/views/notifications.py b/api/views/notifications.py index 1dcb924..677a561 100644 --- a/api/views/notifications.py +++ b/api/views/notifications.py @@ -2,7 +2,7 @@ from django.http import HttpRequest from django.shortcuts import get_object_or_404 from hatchway import ApiResponse, api_view -from activities.models import TimelineEvent +from activities.models import PostInteraction, TimelineEvent from activities.services import TimelineService from api import schemas from api.decorators import scope_required @@ -45,8 +45,15 @@ def notifications( since_id=since_id, limit=limit, ) + interactions = PostInteraction.get_event_interactions( + pager.results, + request.identity, + ) return PaginatingApiResponse( - [schemas.Notification.from_timeline_event(event) for event in pager.results], + [ + schemas.Notification.from_timeline_event(event, interactions=interactions) + for event in pager.results + ], request=request, include_params=["limit", "account_id"], )