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)