Remove special cases for flagging

Remove special cases for flagging

Prior to the new review queue there were a couple special cases where posts would be auto hidden:

  • If a TL3 or above flagged a TL0 post as spam
  • If a TL4 or above flagged a non-staff, non-TL4 post as spam, inappropriate or off topic.

These cases are now removed in favour of the scoring system.

diff --git a/lib/post_action_creator.rb b/lib/post_action_creator.rb
index 120ee3a..47538b1 100644
--- a/lib/post_action_creator.rb
+++ b/lib/post_action_creator.rb
@@ -156,22 +156,9 @@ private
     return if @post.hidden?
     return if !@created_by.staff? && @post.user&.staff?
 
-    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])
-    elsif PostActionType.auto_action_flag_types.include?(@post_action_name)
-      if @created_by.has_trust_level?(TrustLevel[4]) &&
-        !@created_by.staff? &&
-        @post.user&.trust_level != TrustLevel[4]
-
-        @post.hide!(@post_action_type_id, Post.hidden_reasons[:flagged_by_tl4_user])
-      else
-        score = ReviewableFlaggedPost.find_by(target: @post)&.score || 0
-        if score >= Reviewable.score_required_to_hide_post
-          @post.hide!(@post_action_type_id)
-        end
-      end
+    score = ReviewableFlaggedPost.find_by(target: @post)&.score || 0
+    if score >= Reviewable.score_required_to_hide_post
+      @post.hide!(@post_action_type_id)
     end
   end
 
diff --git a/spec/models/post_action_spec.rb b/spec/models/post_action_spec.rb
index ca27c8f..cc2f449 100644
--- a/spec/models/post_action_spec.rb
+++ b/spec/models/post_action_spec.rb
@@ -609,56 +609,6 @@ describe PostAction do
       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 "hide non-tl4 posts that are flagged by a tl4 user" do
-      SiteSetting.site_contact_username = admin.username
-
-      tl4_user = Fabricate(:trust_level_4)
-      user = Fabricate(:leader)
-      post = create_post(user: user)
-
-      PostActionCreator.spam(tl4_user, post)
-
-      post.reload
-
-      expect(post.hidden).to be_truthy
-      expect(post.hidden_at).to be_present
-      expect(post.hidden_reason_id).to eq(Post.hidden_reasons[:flagged_by_tl4_user])
-
-      post = create_post(user: user)
-      PostActionCreator.spam(Fabricate(:leader), post)
-      post.reload
-
-      expect(post.hidden).to be_falsey
-
-      post = create_post(user: user)
-      PostActionCreator.spam(Fabricate(:moderator), post)
-      post.reload
-
-      expect(post.hidden).to be_falsey
-
-      user = Fabricate(:trust_level_4)
-      post = create_post(user: user)
-      PostActionCreator.spam(tl4_user, post)
-      post.reload
-
-      expect(post.hidden).to be_falsey
-    end
-
     it "can flag the topic instead of a post" do
       post1 = create_post
       create_post(topic: post1.topic)

GitHub sha: 4cd620e3

1 Like

This commit has been mentioned on Discourse Meta. There might be relevant details there: