summaryrefslogtreecommitdiffstats
path: root/users
diff options
context:
space:
mode:
Diffstat (limited to 'users')
-rw-r--r--users/models/identity.py19
-rw-r--r--users/models/inbox_message.py2
2 files changed, 20 insertions, 1 deletions
diff --git a/users/models/identity.py b/users/models/identity.py
index a78a451..c26762d 100644
--- a/users/models/identity.py
+++ b/users/models/identity.py
@@ -12,6 +12,7 @@ from django.template.defaultfilters import linebreaks_filter
from django.templatetags.static import static
from django.utils import timezone
+from core.exceptions import ActorMismatchError
from core.html import sanitize_post
from core.ld import canonicalise, media_type_from_filename
from core.uploads import upload_namer
@@ -261,6 +262,24 @@ class Identity(StatorModel):
except cls.DoesNotExist:
pass
+ @classmethod
+ def handle_delete_ap(cls, data):
+ """
+ Takes an incoming update.person message and just forces us to add it
+ to our fetch queue (don't want to bother with two load paths right now)
+ """
+ # Assert that the actor matches the object
+ if data["actor"] != data["object"]:
+ raise ActorMismatchError(
+ f"Actor {data['actor']} trying to delete identity {data['object']}"
+ )
+ # Find by actor
+ try:
+ actor = cls.by_actor_uri(data["actor"])
+ actor.delete()
+ except cls.DoesNotExist:
+ pass
+
### Actor/Webfinger fetching ###
@classmethod
diff --git a/users/models/inbox_message.py b/users/models/inbox_message.py
index fc81d71..a73166a 100644
--- a/users/models/inbox_message.py
+++ b/users/models/inbox_message.py
@@ -67,7 +67,7 @@ class InboxMessageStates(StateGraph):
case "delete":
# If there is no object type, it's probably a profile
if not isinstance(instance.message["object"], dict):
- raise ValueError("Cannot handle activity of type delete")
+ await sync_to_async(Identity.handle_delete_ap)(instance.message)
match instance.message_object_type:
case "tombstone":
await sync_to_async(Post.handle_delete_ap)(instance.message)