diff options
author | Andrew Godwin | 2022-12-11 12:37:28 -0700 |
---|---|---|
committer | Andrew Godwin | 2022-12-12 11:56:49 -0700 |
commit | 20239b5cb7455d593680b17d2d80d2a4850c524d (patch) | |
tree | 1c5705837e17bca50920848d00bfcf1f7c2313af /api/views/accounts.py | |
parent | fc8a21fc5c6809ea115092eeec57e09e984cdd76 (diff) | |
download | takahe-20239b5cb7455d593680b17d2d80d2a4850c524d.tar.gz takahe-20239b5cb7455d593680b17d2d80d2a4850c524d.tar.bz2 takahe-20239b5cb7455d593680b17d2d80d2a4850c524d.zip |
Basic post mutation
Diffstat (limited to 'api/views/accounts.py')
-rw-r--r-- | api/views/accounts.py | 12 |
1 files changed, 7 insertions, 5 deletions
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] |