Discard messages from blocked servers

This commit is contained in:
Andrew Godwin 2022-11-25 18:11:31 -07:00
parent 8ca36fd958
commit 19909bdef0
2 changed files with 8 additions and 1 deletions

View File

@ -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:

View File

@ -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,
)