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/accounts.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'api/views/accounts.py') diff --git a/api/views/accounts.py b/api/views/accounts.py index 1b883e8..43ec75d 100644 --- a/api/views/accounts.py +++ b/api/views/accounts.py @@ -1,12 +1,11 @@ from django.shortcuts import get_object_or_404 -from activities.models import Post +from activities.models import Post, PostInteraction from api import schemas +from api.decorators import identity_required from api.views.base import api_router from users.models import Identity -from ..decorators import identity_required - @api_router.get("/v1/accounts/verify_credentials", response=schemas.Account) @identity_required @@ -69,7 +68,8 @@ def account_statuses( ): identity = get_object_or_404(Identity, pk=id) posts = ( - identity.posts.public() + identity.posts.not_hidden() + .unlisted(include_replies=not exclude_replies) .select_related("author") .prefetch_related("attachments") .order_by("-created") @@ -91,4 +91,6 @@ def account_statuses( # invert the ordering to accomodate anchor_post = Post.objects.get(pk=min_id) posts = posts.filter(created__gt=anchor_post.created).order_by("created") - return [post.to_mastodon_json() for post in posts[:limit]] + posts = list(posts[:limit]) + interactions = PostInteraction.get_post_interactions(posts, request.identity) + return [post.to_mastodon_json(interactions=interactions) for post in posts] -- cgit v1.2.3