FIX: do not agree flags by default when deleting posts

This commit is contained in:
Arpit Jalan
2018-11-26 21:28:37 +05:30
parent 3453707784
commit cb6fc8057b
3 changed files with 36 additions and 27 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[:agree_flags]
agree_with_flags
else
defer_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,
@ -237,10 +241,13 @@ class PostDestroyer
}
)
end
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 = {