Add/Remove activity for featured posts

This commit is contained in:
freamon 2024-03-19 15:38:35 +00:00
parent 136cb64a69
commit e49cf220e9

View file

@ -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! target_ap_id = request_json['object']['object']['object'] # object object object!
post = undo_vote(activity_log, comment, post, target_ap_id, user) post = undo_vote(activity_log, comment, post, target_ap_id, user)
activity_log.result = 'success' 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: else:
activity_log.exception_message = 'Invalid type for Announce' activity_log.exception_message = 'Invalid type for Announce'