summaryrefslogtreecommitdiffstats
path: root/activities/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 /activities/views
parentc588567c8698700cd347d9b8f884a7967890aa58 (diff)
downloadtakahe-12567f6891ad591390cbd74c0e7b77a4a024a24e.tar.gz
takahe-12567f6891ad591390cbd74c0e7b77a4a024a24e.tar.bz2
takahe-12567f6891ad591390cbd74c0e7b77a4a024a24e.zip
Identity admin/moderation
Diffstat (limited to 'activities/views')
-rw-r--r--activities/views/posts.py6
-rw-r--r--activities/views/timelines.py4
2 files changed, 9 insertions, 1 deletions
diff --git a/activities/views/posts.py b/activities/views/posts.py
index 1b8676d..a3810e0 100644
--- a/activities/views/posts.py
+++ b/activities/views/posts.py
@@ -1,6 +1,6 @@
from django.core.exceptions import PermissionDenied
from django.db import models
-from django.http import JsonResponse
+from django.http import Http404, JsonResponse
from django.shortcuts import get_object_or_404, redirect, render
from django.utils.decorators import method_decorator
from django.views.decorators.vary import vary_on_headers
@@ -10,6 +10,7 @@ from activities.models import Post, PostInteraction, PostStates
from core.decorators import cache_page_by_ap_json
from core.ld import canonicalise
from users.decorators import identity_required
+from users.models import Identity
from users.shortcuts import by_handle_or_404
@@ -23,6 +24,8 @@ class Individual(TemplateView):
def get(self, request, handle, post_id):
self.identity = by_handle_or_404(self.request, handle, local=False)
+ if self.identity.blocked:
+ raise Http404("Blocked user")
self.post_obj = get_object_or_404(self.identity.posts, pk=post_id)
# If they're coming in looking for JSON, they want the actor
if request.ap_json:
@@ -66,6 +69,7 @@ class Individual(TemplateView):
),
in_reply_to=self.post_obj.object_uri,
)
+ .exclude(author__restriction=Identity.Restriction.blocked)
.distinct()
.select_related("author__domain")
.prefetch_related("emojis")
diff --git a/activities/views/timelines.py b/activities/views/timelines.py
index 84e490f..9e4bcfb 100644
--- a/activities/views/timelines.py
+++ b/activities/views/timelines.py
@@ -7,6 +7,7 @@ from django.views.generic import FormView, ListView
from activities.models import Hashtag, Post, PostInteraction, TimelineEvent
from core.decorators import cache_page
from users.decorators import identity_required
+from users.models import Identity
from .compose import Compose
@@ -75,6 +76,7 @@ class Tag(ListView):
def get_queryset(self):
return (
Post.objects.public()
+ .filter(author__restriction=Identity.Restriction.none)
.tagged_with(self.hashtag)
.select_related("author")
.prefetch_related("attachments", "mentions")
@@ -105,6 +107,7 @@ class Local(ListView):
def get_queryset(self):
return (
Post.objects.local_public()
+ .filter(author__restriction=Identity.Restriction.none)
.select_related("author", "author__domain")
.prefetch_related("attachments", "mentions", "emojis")
.order_by("-created")
@@ -133,6 +136,7 @@ class Federated(ListView):
Post.objects.filter(
visibility=Post.Visibilities.public, in_reply_to__isnull=True
)
+ .filter(author__restriction=Identity.Restriction.none)
.select_related("author", "author__domain")
.prefetch_related("attachments", "mentions", "emojis")
.order_by("-created")