Skip to content

A platform for community discussion. Free, open, simple.

FIX: Put back the TL3 -> TL0 spam thing

Robin Wardc3bbf643b16e
diff --git a/lib/post_action_creator.rb b/lib/post_action_creator.rb
index 47538b1b459..215345c4250 100644
--- a/lib/post_action_creator.rb
+++ b/lib/post_action_creator.rb
@@ -156,6 +156,15 @@ private
return if @post.hidden?
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
if score >= Reviewable.score_required_to_hide_post
@post.hide!(@post_action_type_id)
diff --git a/spec/models/post_action_spec.rb b/spec/models/post_action_spec.rb
index cc2f449b1ca..80ff626e6c3 100644
--- a/spec/models/post_action_spec.rb
+++ b/spec/models/post_action_spec.rb
@@ -608,6 +608,20 @@ describe PostAction do
post.reload
expect(post.hidden).to eq(true)
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
post1 = create_post