Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

return 410 Gone for deleted identity #692

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions users/models/identity.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand Down
7 changes: 6 additions & 1 deletion users/views/identity.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import string
from datetime import timezone

from django import forms
from django.contrib.auth.decorators import login_required
from django.contrib.syndication.views import Feed
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
Expand Down Expand Up @@ -64,10 +66,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 and tz.now() - identity.deleted > tz.timedelta(days=3):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you not inline this formula? It's not complicated, but it is subtle and it took me a moment to figure out what it was doing and why.

r.status_code = 410
return r

def get_queryset(self):
return TimelineService(None).identity_public(
Expand Down
Loading