From 70638c39d1145891c06aa32566d75289573a3373 Mon Sep 17 00:00:00 2001 From: freamon Date: Sun, 24 Nov 2024 21:30:41 +0000 Subject: [PATCH] apf part 31: Announce / Undo / Lock --- app/activitypub/routes.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/app/activitypub/routes.py b/app/activitypub/routes.py index 1db3c44b..d83b0759 100644 --- a/app/activitypub/routes.py +++ b/app/activitypub/routes.py @@ -1070,6 +1070,20 @@ def process_inbox_request(request_json, store_ap_json): log_incoming_ap(request_json['id'], APLOG_UNDO_VOTE, APLOG_FAILURE, request_json if store_ap_json else None, 'Unfound object ' + target_ap_id) return + if request_json['object']['object']['type'] == 'Lock': # Announce of undo of post lock + mod = user + post_id = request_json['object']['object']['object'] + post = Post.query.filter_by(ap_id=post_id).first() + if post: + if post.community.is_moderator(mod) or post.community.is_instance_admin(mod): + post.comments_enabled = True + db.session.commit() + log_incoming_ap(request_json['id'], APLOG_LOCK, APLOG_SUCCESS, request_json if store_ap_json else None) + else: + log_incoming_ap(request_json['id'], APLOG_LOCK, APLOG_FAILURE, request_json if store_ap_json else None, 'Lock: Does not have permission') + else: + log_incoming_ap(request_json['id'], APLOG_LOCK, APLOG_FAILURE, request_json if store_ap_json else None, 'Lock: post not found') + return # -- below this point is code that will be incrementally replaced to use log_incoming_ap() instead --