From 19909bdef06969d332e00db58b2023f9e492bb4c Mon Sep 17 00:00:00 2001 From: Andrew Godwin Date: Fri, 25 Nov 2022 18:11:31 -0700 Subject: Discard messages from blocked servers --- users/views/activitypub.py | 7 +++++++ users/views/admin/federation.py | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'users/views') diff --git a/users/views/activitypub.py b/users/views/activitypub.py index 2c7020a..cca57fb 100644 --- a/users/views/activitypub.py +++ b/users/views/activitypub.py @@ -150,6 +150,13 @@ class Inbox(View): f"Inbox error: cannot fetch actor {document['actor']}" ) return HttpResponseBadRequest("Cannot retrieve actor") + # See if it's from a blocked domain + if identity.domain.blocked: + # I love to lie! Throw it away! + exceptions.capture_message( + f"Inbox: Discarded message from {identity.domain}" + ) + return HttpResponse(status=202) # If there's a "signature" payload, verify against that if "signature" in document: try: diff --git a/users/views/admin/federation.py b/users/views/admin/federation.py index da8209a..4d6b179 100644 --- a/users/views/admin/federation.py +++ b/users/views/admin/federation.py @@ -30,7 +30,7 @@ class FederationEdit(FormView): class form_class(forms.Form): blocked = forms.BooleanField( - help_text="If this domain is blocked from interacting with this server", + help_text="If this domain is blocked from interacting with this server.\nAll incoming posts from this domain will be irrecoverably dropped.", widget=forms.Select(choices=[(True, "Blocked"), (False, "Not Blocked")]), required=False, ) -- cgit v1.2.3