From 537dd41740d018ff65cd7c4a9c4ab4503db9e84c Mon Sep 17 00:00:00 2001 From: freamon Date: Thu, 13 Jun 2024 19:09:34 +0100 Subject: [PATCH] Lemmy can send Announce/Update without ever sending an Announce/Create --- app/activitypub/routes.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/activitypub/routes.py b/app/activitypub/routes.py index 039e9389..541f0aa4 100644 --- a/app/activitypub/routes.py +++ b/app/activitypub/routes.py @@ -754,6 +754,11 @@ def process_inbox_request(request_json, activitypublog_id, ip_address): activity_log.result = 'success' else: activity_log.exception_message = 'Post not found' + # Lemmy can send Announce/Update without ever sending an Announce/Create + # presumably happens with quick edits after creation (e.g. https://midwest.social/post/13348959) + # Pretend this activity was the Create, and try again. + request_json['object']['type'] = 'Create' + process_inbox_request(request_json, activitypublog_id, ip_address) elif request_json['object']['object']['type'] == 'Note': reply = PostReply.query.filter_by(ap_id=request_json['object']['object']['id']).first() if reply: @@ -766,6 +771,9 @@ def process_inbox_request(request_json, activitypublog_id, ip_address): activity_log.result = 'success' else: activity_log.exception_message = 'PostReply not found' + # As with Update/Page, pretend this activity was the Create, and try again. + request_json['object']['type'] = 'Create' + process_inbox_request(request_json, activitypublog_id, ip_address) elif request_json['object']['type'] == 'Undo': if request_json['object']['object']['type'] == 'Like' or request_json['object']['object']['type'] == 'Dislike': activity_log.activity_type = request_json['object']['object']['type']