mirror of
https://github.com/discourse/discourse.git
synced 2025-03-06 11:19:51 +00:00
FIX: Correctly ignore/approve replies when acting on a flagged post (#8425)
This commit is contained in:
parent
b6e08c06c5
commit
1c9d18f094
@ -228,7 +228,7 @@ class ReviewableFlaggedPost < Reviewable
|
|||||||
|
|
||||||
def perform_delete_and_agree_replies(performed_by, args)
|
def perform_delete_and_agree_replies(performed_by, args)
|
||||||
result = agree(performed_by, args)
|
result = agree(performed_by, args)
|
||||||
PostDestroyer.delete_with_replies(performed_by, post, self)
|
PostDestroyer.delete_with_replies(performed_by, post, self, defer_reply_flags: false)
|
||||||
result
|
result
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -39,11 +39,11 @@ class PostDestroyer
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.delete_with_replies(performed_by, post, reviewable = nil)
|
def self.delete_with_replies(performed_by, post, reviewable = nil, defer_reply_flags: true)
|
||||||
reply_ids = post.reply_ids(Guardian.new(performed_by), only_replies_to_single_post: false)
|
reply_ids = post.reply_ids(Guardian.new(performed_by), only_replies_to_single_post: false)
|
||||||
replies = Post.where(id: reply_ids.map { |r| r[:id] })
|
replies = Post.where(id: reply_ids.map { |r| r[:id] })
|
||||||
PostDestroyer.new(performed_by, post, reviewable: reviewable).destroy
|
PostDestroyer.new(performed_by, post, reviewable: reviewable).destroy
|
||||||
replies.each { |reply| PostDestroyer.new(performed_by, reply).destroy }
|
replies.each { |reply| PostDestroyer.new(performed_by, reply, defer_flags: defer_reply_flags).destroy }
|
||||||
end
|
end
|
||||||
|
|
||||||
def initialize(user, post, opts = {})
|
def initialize(user, post, opts = {})
|
||||||
|
@ -798,4 +798,28 @@ describe PostDestroyer do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe '#delete_with_replies' do
|
||||||
|
let(:reporter) { Discourse.system_user }
|
||||||
|
fab!(:post) { Fabricate(:post) }
|
||||||
|
|
||||||
|
before do
|
||||||
|
reply = Fabricate(:post, topic: post.topic)
|
||||||
|
post.update(replies: [reply])
|
||||||
|
PostActionCreator.off_topic(reporter, post)
|
||||||
|
|
||||||
|
@reviewable_reply = PostActionCreator.off_topic(reporter, reply).reviewable
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'ignores flagged replies' do
|
||||||
|
PostDestroyer.delete_with_replies(reporter, post)
|
||||||
|
|
||||||
|
expect(@reviewable_reply.reload.status).to eq Reviewable.statuses[:ignored]
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'approves flagged replies' do
|
||||||
|
PostDestroyer.delete_with_replies(reporter, post, defer_reply_flags: false)
|
||||||
|
|
||||||
|
expect(@reviewable_reply.reload.status).to eq Reviewable.statuses[:approved]
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user