summaryrefslogtreecommitdiffstats
path: root/api/views
diff options
context:
space:
mode:
authorAndrew Godwin2022-12-16 19:42:48 -0700
committerAndrew Godwin2022-12-16 19:42:48 -0700
commit12567f6891ad591390cbd74c0e7b77a4a024a24e (patch)
tree39a6bab590d3f1bde3802854d4a1175780404276 /api/views
parentc588567c8698700cd347d9b8f884a7967890aa58 (diff)
downloadtakahe-12567f6891ad591390cbd74c0e7b77a4a024a24e.tar.gz
takahe-12567f6891ad591390cbd74c0e7b77a4a024a24e.tar.bz2
takahe-12567f6891ad591390cbd74c0e7b77a4a024a24e.zip
Identity admin/moderation
Diffstat (limited to 'api/views')
-rw-r--r--api/views/accounts.py8
-rw-r--r--api/views/timelines.py3
2 files changed, 9 insertions, 2 deletions
diff --git a/api/views/accounts.py b/api/views/accounts.py
index 4f1903b..d0aeb08 100644
--- a/api/views/accounts.py
+++ b/api/views/accounts.py
@@ -48,7 +48,9 @@ def account_relationships(request):
@api_router.get("/v1/accounts/{id}", response=schemas.Account)
@identity_required
def account(request, id: str):
- identity = get_object_or_404(Identity, pk=id)
+ identity = get_object_or_404(
+ Identity.objects.exclude(restriction=Identity.Restriction.blocked), pk=id
+ )
return identity.to_mastodon_json()
@@ -67,7 +69,9 @@ def account_statuses(
min_id: str | None = None,
limit: int = 20,
):
- identity = get_object_or_404(Identity, pk=id)
+ identity = get_object_or_404(
+ Identity.objects.exclude(restriction=Identity.Restriction.blocked), pk=id
+ )
queryset = (
identity.posts.not_hidden()
.unlisted(include_replies=not exclude_replies)
diff --git a/api/views/timelines.py b/api/views/timelines.py
index 8f4ac78..b14586f 100644
--- a/api/views/timelines.py
+++ b/api/views/timelines.py
@@ -3,6 +3,7 @@ from api import schemas
from api.decorators import identity_required
from api.pagination import MastodonPaginator
from api.views.base import api_router
+from users.models import Identity
@api_router.get("/v1/timelines/home", response=list[schemas.Status])
@@ -52,6 +53,7 @@ def public(
):
queryset = (
Post.objects.public()
+ .filter(author__restriction=Identity.Restriction.none)
.select_related("author")
.prefetch_related("attachments")
.order_by("-created")
@@ -90,6 +92,7 @@ def hashtag(
limit = 40
queryset = (
Post.objects.public()
+ .filter(author__restriction=Identity.Restriction.none)
.tagged_with(hashtag)
.select_related("author")
.prefetch_related("attachments")