Only decrement post.reply_count for deletions if reply author wasn't a bot

This commit is contained in:
freamon 2024-06-18 16:42:24 +01:00
parent 786a24432b
commit e6c65bd393
2 changed files with 6 additions and 3 deletions

View file

@ -1030,6 +1030,7 @@ def process_inbox_request(request_json, activitypublog_id, ip_address):
if can_delete(request_json['actor'], reply):
reply.body_html = '<p><em>deleted</em></p>'
reply.body = 'deleted'
if not reply.author.bot:
reply.post.reply_count -= 1
reply.deleted = True
announce_activity_to_followers(reply.community, reply.author, request_json)

View file

@ -1414,6 +1414,7 @@ def delete_post_or_comment_task(user_ap_id, community_ap_id, to_be_deleted_ap_id
community.post_count -= 1
db.session.commit()
elif isinstance(to_delete, PostReply):
if not to_delete.author.bot:
to_delete.post.reply_count -= 1
if to_delete.has_replies():
to_delete.body = 'Deleted by author' if to_delete.author.id == deletor.id else 'Deleted by moderator'
@ -1454,6 +1455,7 @@ def remove_data_from_banned_user_task(deletor_ap_id, user_ap_id, target):
return
for post_reply in post_replies:
if not user.bot:
post_reply.post.reply_count -= 1
if post_reply.has_replies():
post_reply.body = 'Banned'