FIX: defer flags (only) when handling a flag and deleting replies (#6702)

This commit is contained in:
Arpit Jalan
2018-11-29 22:44:18 +05:30
committed by GitHub
parent 4a8f21d387
commit 40f10855c6
6 changed files with 52 additions and 22 deletions

View File

@@ -147,7 +147,11 @@ class PostDestroyer
update_user_counts
TopicUser.update_post_action_cache(post_id: @post.id)
DB.after_commit do
agree_with_flags
if @opts[:defer_flags].to_s == "true"
defer_flags
else
agree_with_flags
end
end
end
@@ -225,7 +229,7 @@ class PostDestroyer
if @post.has_active_flag? && @user.id > 0 && @user.staff?
Jobs.enqueue(
:send_system_message,
user_id: @post.user.id,
user_id: @post.user_id,
message_type: :flags_agreed_and_post_deleted,
message_options: {
url: @post.url,
@@ -241,6 +245,10 @@ class PostDestroyer
PostAction.agree_flags!(@post, @user, delete_post: true)
end
def defer_flags
PostAction.defer_flags!(@post, @user, delete_post: true)
end
def trash_user_actions
UserAction.where(target_post_id: @post.id).each do |ua|
row = {