From e49cf220e9dddd7b030602a3bae0dfd066270f10 Mon Sep 17 00:00:00 2001 From: freamon Date: Tue, 19 Mar 2024 15:38:35 +0000 Subject: [PATCH] Add/Remove activity for featured posts --- app/activitypub/routes.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/app/activitypub/routes.py b/app/activitypub/routes.py index 9df2ef01..1084de75 100644 --- a/app/activitypub/routes.py +++ b/app/activitypub/routes.py @@ -666,6 +666,24 @@ def process_inbox_request(request_json, activitypublog_id, ip_address): target_ap_id = request_json['object']['object']['object'] # object object object! post = undo_vote(activity_log, comment, post, target_ap_id, user) activity_log.result = 'success' + elif request_json['object']['type'] == 'Add': + activity_log.activity_type = request_json['object']['type'] + featured_url = Community.query.filter(Community.ap_public_url == request_json['actor']).first().ap_featured_url + if featured_url: + if 'target' in request_json['object'] and featured_url == request_json['object']['target']: + post = Post.query.filter(Post.ap_id == request_json['object']['object']).first() + if post: + post.sticky = True + activity_log.result = 'success' + elif request_json['object']['type'] == 'Remove': + activity_log.activity_type = request_json['object']['type'] + featured_url = Community.query.filter(Community.ap_public_url == request_json['actor']).first().ap_featured_url + if featured_url: + if 'target' in request_json['object'] and featured_url == request_json['object']['target']: + post = Post.query.filter(Post.ap_id == request_json['object']['object']).first() + if post: + post.sticky = False + activity_log.result = 'success' else: activity_log.exception_message = 'Invalid type for Announce'