FIX: user-deleted posts with deferred flags can be destroyed

This commit is contained in:
Neil Lalonde 2018-08-09 14:54:23 -04:00
parent 04658bb2f1
commit d77dccc636
2 changed files with 10 additions and 3 deletions

View File

@ -26,9 +26,10 @@ class PostDestroyer
.where("NOT EXISTS (
SELECT 1
FROM 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|

View File

@ -91,6 +91,12 @@ describe PostDestroyer do
reply1.reload
expect(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)
end
it 'uses the delete_removed_posts_after site setting' do