Fixed #599: Interaction state not present on notifications

This commit is contained in:
Andrew Godwin 2023-07-05 07:58:54 -06:00
parent 542e3836af
commit e34e4c0c77
2 changed files with 11 additions and 3 deletions

View File

@ -273,8 +273,9 @@ class Notification(Schema):
def from_timeline_event( def from_timeline_event(
cls, cls,
event: activities_models.TimelineEvent, event: activities_models.TimelineEvent,
interactions=None,
) -> "Notification": ) -> "Notification":
return cls(**event.to_mastodon_notification_json()) return cls(**event.to_mastodon_notification_json(interactions=interactions))
class Tag(Schema): class Tag(Schema):

View File

@ -2,7 +2,7 @@ from django.http import HttpRequest
from django.shortcuts import get_object_or_404 from django.shortcuts import get_object_or_404
from hatchway import ApiResponse, api_view from hatchway import ApiResponse, api_view
from activities.models import TimelineEvent from activities.models import PostInteraction, TimelineEvent
from activities.services import TimelineService from activities.services import TimelineService
from api import schemas from api import schemas
from api.decorators import scope_required from api.decorators import scope_required
@ -45,8 +45,15 @@ def notifications(
since_id=since_id, since_id=since_id,
limit=limit, limit=limit,
) )
interactions = PostInteraction.get_event_interactions(
pager.results,
request.identity,
)
return PaginatingApiResponse( 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, request=request,
include_params=["limit", "account_id"], include_params=["limit", "account_id"],
) )