mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 14:38:17 +08:00
FIX: Reviews that are auto-hidden by a trusted spam flagger should always have enough weight. (#10284)
This commit is contained in:
parent
300e30dcbf
commit
9fc7bd5797
|
@ -188,13 +188,7 @@ private
|
||||||
return if !@created_by.staff? && @post.user&.staff?
|
return if !@created_by.staff? && @post.user&.staff?
|
||||||
return unless PostActionType.auto_action_flag_types.include?(@post_action_name)
|
return unless PostActionType.auto_action_flag_types.include?(@post_action_name)
|
||||||
|
|
||||||
# Special case: If you have TL3 and the user is TL0, and the flag is spam,
|
if trusted_spam_flagger?
|
||||||
# hide it immediately.
|
|
||||||
if SiteSetting.high_trust_flaggers_auto_hide_posts &&
|
|
||||||
@post_action_name == :spam &&
|
|
||||||
@created_by.has_trust_level?(TrustLevel[3]) &&
|
|
||||||
@post.user&.trust_level == TrustLevel[0]
|
|
||||||
|
|
||||||
@post.hide!(@post_action_type_id, Post.hidden_reasons[:flagged_by_tl3_user])
|
@post.hide!(@post_action_type_id, Post.hidden_reasons[:flagged_by_tl3_user])
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
@ -205,6 +199,15 @@ private
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Special case: If you have TL3 and the user is TL0, and the flag is spam,
|
||||||
|
# hide it immediately.
|
||||||
|
def trusted_spam_flagger?
|
||||||
|
SiteSetting.high_trust_flaggers_auto_hide_posts &&
|
||||||
|
@post_action_name == :spam &&
|
||||||
|
@created_by.has_trust_level?(TrustLevel[3]) &&
|
||||||
|
@post.user&.trust_level == TrustLevel[0]
|
||||||
|
end
|
||||||
|
|
||||||
def create_post_action
|
def create_post_action
|
||||||
@targets_topic = !!(
|
@targets_topic = !!(
|
||||||
if @flag_topic && @post.topic
|
if @flag_topic && @post.topic
|
||||||
|
@ -315,7 +318,8 @@ private
|
||||||
created_at: @created_at,
|
created_at: @created_at,
|
||||||
take_action: @take_action,
|
take_action: @take_action,
|
||||||
meta_topic_id: @meta_post&.topic_id,
|
meta_topic_id: @meta_post&.topic_id,
|
||||||
reason: @reason
|
reason: @reason,
|
||||||
|
force_review: trusted_spam_flagger?
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -103,11 +103,10 @@ describe PostActionCreator do
|
||||||
before do
|
before do
|
||||||
user.trust_level = TrustLevel[3]
|
user.trust_level = TrustLevel[3]
|
||||||
post.user.trust_level = TrustLevel[0]
|
post.user.trust_level = TrustLevel[0]
|
||||||
|
SiteSetting.high_trust_flaggers_auto_hide_posts = true
|
||||||
end
|
end
|
||||||
|
|
||||||
it "hides the post when the flagger is a TL3 user and the poster is a TL0 user" do
|
it "hides the post when the flagger is a TL3 user and the poster is a TL0 user" do
|
||||||
SiteSetting.high_trust_flaggers_auto_hide_posts = true
|
|
||||||
|
|
||||||
result = PostActionCreator.create(user, post, :spam)
|
result = PostActionCreator.create(user, post, :spam)
|
||||||
|
|
||||||
expect(post.hidden?).to eq(true)
|
expect(post.hidden?).to eq(true)
|
||||||
|
@ -120,6 +119,17 @@ describe PostActionCreator do
|
||||||
|
|
||||||
expect(post.hidden?).to eq(false)
|
expect(post.hidden?).to eq(false)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'forces the review to surpass the minimum priority threshold' do
|
||||||
|
Reviewable.set_priorities(high: 40.0)
|
||||||
|
SiteSetting.reviewable_default_visibility = 'high'
|
||||||
|
result = PostActionCreator.create(user, post, :spam)
|
||||||
|
|
||||||
|
reviewable = result.reviewable
|
||||||
|
reviewable_score = reviewable.reviewable_scores.find_by(user: user)
|
||||||
|
|
||||||
|
expect(reviewable_score.score).to eq(Reviewable.min_score_for_priority)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "existing reviewable" do
|
context "existing reviewable" do
|
||||||
|
|
Loading…
Reference in New Issue
Block a user