Skip to content

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

FIX: do not add a moderator post when post is flagged via direct message (#6100)

Maja Komela9ebad3f6cbb
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