A platform for community discussion. Free, open, simple.
FIX: user-deleted posts with deferred flags can be destroyed
Neil Lalonded77dccc636b3
diff --git a/lib/post_destroyer.rb b/lib/post_destroyer.rbindex ff808b418f6..3b68fc60aa9 100644--- a/lib/post_destroyer.rb+++ b/lib/post_destroyer.rb@@ -26,9 +26,10 @@ class PostDestroyer.where("NOT EXISTS (SELECT 1FROM post_actions pa- WHERE pa.post_id = posts.id AND- pa.deleted_at IS NULL AND- pa.post_action_type_id IN (?)+ WHERE pa.post_id = posts.id+ AND pa.deleted_at IS NULL+ AND pa.deferred_at IS NULL+ AND pa.post_action_type_id IN (?))", PostActionType.notify_flag_type_ids).find_each do |post|diff --git a/spec/components/post_destroyer_spec.rb b/spec/components/post_destroyer_spec.rbindex f1c772478f3..ddd00be3079 100644--- a/spec/components/post_destroyer_spec.rb+++ b/spec/components/post_destroyer_spec.rb@@ -91,6 +91,12 @@ describe PostDestroyer doreply1.reloadexpect(reply1.deleted_at).to eq(nil)+ # defer the flag, we should be able to delete the stub+ PostAction.defer_flags!(reply1, Discourse.system_user)+ PostDestroyer.destroy_stubs++ reply1.reload+ expect(reply1.deleted_at).to_not eq(nil)endit 'uses the delete_removed_posts_after site setting' do