From a9ebad3f6cbba7a2e873e0f9cd18f4c4d2c59811 Mon Sep 17 00:00:00 2001 From: Maja Komel Date: Wed, 18 Jul 2018 23:18:14 +0200 Subject: [PATCH] FIX: do not add a moderator post when post is flagged via direct message (#6100) --- app/models/post_action.rb | 2 +- spec/models/post_action_spec.rb | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/app/models/post_action.rb b/app/models/post_action.rb index ecf453f756f..966286d74e3 100644 --- a/app/models/post_action.rb +++ b/app/models/post_action.rb @@ -152,7 +152,7 @@ class PostAction < ActiveRecord::Base def self.agree_flags!(post, moderator, delete_post = false) actions = PostAction.active .where(post_id: post.id) - .where(post_action_type_id: PostActionType.flag_types.values) + .where(post_action_type_id: PostActionType.notify_flag_types.values) trigger_spam = false actions.each do |action| diff --git a/spec/models/post_action_spec.rb b/spec/models/post_action_spec.rb index 96fe9ea0d2b..07c9b49c063 100644 --- a/spec/models/post_action_spec.rb +++ b/spec/models/post_action_spec.rb @@ -672,6 +672,20 @@ describe PostAction do expect(user_notifications.last.topic).to eq(topic) end + it "should not add a moderator post when post is flagged via private message" do + SiteSetting.queue_jobs = false + post = Fabricate(:post) + user = Fabricate(:user) + action = PostAction.act(user, post, PostActionType.types[:notify_user], message: "WAT") + topic = action.reload.related_post.topic + expect(user.notifications.count).to eq(0) + + SiteSetting.auto_respond_to_flag_actions = true + PostAction.agree_flags!(post, admin) + + user_notifications = user.notifications + expect(user_notifications.count).to eq(0) + end end describe "rate limiting" do