From 4cd620e36eaefa29035a859f4f74726a2d0e7a05 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Tue, 17 Sep 2019 13:37:22 -0400 Subject: [PATCH] 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. --- lib/post_action_creator.rb | 19 ++----------- spec/models/post_action_spec.rb | 50 --------------------------------- 2 files changed, 3 insertions(+), 66 deletions(-) diff --git a/lib/post_action_creator.rb b/lib/post_action_creator.rb index 120ee3a456..47538b1b45 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 ca27c8f856..cc2f449b1c 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)