FIX: Put back the TL3 -> TL0 spam thing

We talked about it and decided it's still relevant in the score world.
This commit is contained in:
Robin Ward 2019-09-17 15:58:30 -04:00
parent 215f6d97e5
commit c3bbf643b1
2 changed files with 23 additions and 0 deletions

View File

@ -156,6 +156,15 @@ private
return if @post.hidden? return if @post.hidden?
return if !@created_by.staff? && @post.user&.staff? return if !@created_by.staff? && @post.user&.staff?
# Special case: If you have TL3 and the user is TL0, and the flag is spam,
# hide it immediately.
if @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])
return
end
score = ReviewableFlaggedPost.find_by(target: @post)&.score || 0 score = ReviewableFlaggedPost.find_by(target: @post)&.score || 0
if score >= Reviewable.score_required_to_hide_post if score >= Reviewable.score_required_to_hide_post
@post.hide!(@post_action_type_id) @post.hide!(@post_action_type_id)

View File

@ -608,6 +608,20 @@ describe PostAction do
post.reload post.reload
expect(post.hidden).to eq(true) expect(post.hidden).to eq(true)
end end
it "hide tl0 posts that are flagged as spam by a tl3 user" do
newuser = Fabricate(:newuser)
post = create_post(user: newuser)
Discourse.stubs(:site_contact_user).returns(admin)
PostActionCreator.spam(Fabricate(:leader), post)
post.reload
expect(post.hidden).to eq(true)
expect(post.hidden_at).to be_present
expect(post.hidden_reason_id).to eq(Post.hidden_reasons[:flagged_by_tl3_user])
end
it "can flag the topic instead of a post" do it "can flag the topic instead of a post" do
post1 = create_post post1 = create_post