From 02bda3ad9bccfc24ad77f64e6ef5362d587f26ac Mon Sep 17 00:00:00 2001 From: Henri Dickson <90480431+alphatownsman@users.noreply.github.com> Date: Fri, 19 Jan 2024 00:35:30 -0500 Subject: [PATCH 1/2] return 410 Gone for deleted identity --- users/models/identity.py | 4 ++-- users/views/identity.py | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/users/models/identity.py b/users/models/identity.py index f65ad0bde..df7d9c988 100644 --- a/users/models/identity.py +++ b/users/models/identity.py @@ -55,7 +55,7 @@ class IdentityStates(StateGraph): edited = State(try_interval=300, attempt_immediately=True) deleted = State(try_interval=300, attempt_immediately=True) - deleted_fanned_out = State(delete_after=86400 * 7) + deleted_fanned_out = State(externally_progressed=True) moved = State(try_interval=300, attempt_immediately=True) moved_fanned_out = State(externally_progressed=True) @@ -582,7 +582,7 @@ def to_ap(self): self.ensure_uris() response = { "id": self.actor_uri, - "type": self.actor_type.title(), + "type": "Tombstone" if self.deleted else self.actor_type.title(), "inbox": self.inbox_uri, "outbox": self.outbox_uri, "featured": self.featured_collection_uri, diff --git a/users/views/identity.py b/users/views/identity.py index 028e49a95..11bb47091 100644 --- a/users/views/identity.py +++ b/users/views/identity.py @@ -64,10 +64,13 @@ def serve_actor(self, identity): # If this not a local actor, redirect to their canonical URI if not identity.local: return redirect(identity.actor_uri) - return JsonResponse( + r = JsonResponse( canonicalise(identity.to_ap(), include_security=True), content_type="application/activity+json", ) + if identity.deleted: + r.status_code = 410 + return r def get_queryset(self): return TimelineService(None).identity_public( From bd4bfd45844f80732ef038dbdb655d9f2a9526aa Mon Sep 17 00:00:00 2001 From: Henri Dickson <90480431+alphatownsman@users.noreply.github.com> Date: Sat, 24 Feb 2024 10:41:35 -0500 Subject: [PATCH 2/2] improve 410 gone --- users/views/identity.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/users/views/identity.py b/users/views/identity.py index 11bb47091..873a9baea 100644 --- a/users/views/identity.py +++ b/users/views/identity.py @@ -1,4 +1,5 @@ import string +from datetime import timezone from django import forms from django.contrib.auth.decorators import login_required @@ -6,6 +7,7 @@ from django.core import validators from django.http import Http404, JsonResponse from django.shortcuts import redirect +from django.utils import timezone as tz from django.utils.decorators import method_decorator from django.utils.feedgenerator import Rss201rev2Feed from django.utils.xmlutils import SimplerXMLGenerator @@ -68,7 +70,7 @@ def serve_actor(self, identity): canonicalise(identity.to_ap(), include_security=True), content_type="application/activity+json", ) - if identity.deleted: + if identity.deleted and tz.now() - identity.deleted > tz.timedelta(days=3): r.status_code = 410 return r