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

This commit is contained in:
Maja Komel 2018-07-18 23:18:14 +02:00 committed by Régis Hanol
parent c1249d9e1d
commit a9ebad3f6c
2 changed files with 15 additions and 1 deletions

View File

@ -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|

View File

@ -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