diff --git a/app/models/post_action.rb b/app/models/post_action.rb index c1d75d551..5a7514f45 100644 --- a/app/models/post_action.rb +++ b/app/models/post_action.rb @@ -183,6 +183,7 @@ class PostAction < ActiveRecord::Base end def add_moderator_post_if_needed(moderator, disposition, delete_post=false) + return if !SiteSetting.auto_respond_to_flag_actions return if related_post.nil? || related_post.topic.nil? return if moderator_already_replied?(related_post.topic, moderator) message_key = "flags_dispositions.#{disposition}" diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index fa23184bd..c8347330d 100644 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -1036,6 +1036,8 @@ en: num_flaggers_to_close_topic: "Minimum number of unique flaggers that is required to automatically pause a topic for intervention" num_flags_to_close_topic: "Minimum number of active flags that is required to automatically pause a topic for intervention" + auto_respond_to_flag_actions: "Enable automatic reply when disposing a flag." + reply_by_email_enabled: "Enable replying to topics via email." reply_by_email_address: "Template for reply by email incoming email address, for example: %{reply_key}@reply.example.com or replies+%{reply_key}@example.com" diff --git a/config/site_settings.yml b/config/site_settings.yml index c2fa4cc6a..d62689a4e 100644 --- a/config/site_settings.yml +++ b/config/site_settings.yml @@ -622,6 +622,7 @@ spam: max_age_unmatched_ips: 365 num_flaggers_to_close_topic: 5 num_flags_to_close_topic: 12 + auto_respond_to_flag_actions: true rate_limits: unique_posts_mins: diff --git a/spec/models/post_action_spec.rb b/spec/models/post_action_spec.rb index 6e4645dc2..b3700ff46 100644 --- a/spec/models/post_action_spec.rb +++ b/spec/models/post_action_spec.rb @@ -460,9 +460,23 @@ describe PostAction do describe ".add_moderator_post_if_needed" do - it "should not generate a notification for auto-message" do + it "should not add a moderator post when it's disabled" do post = create_post + action = PostAction.act(moderator, post, PostActionType.types[:spam], message: "WAT") + action.reload + topic = action.related_post.topic + expect(topic.posts.count).to eq(1) + + SiteSetting.expects(:auto_respond_to_flag_actions).returns(false) + PostAction.agree_flags!(post, admin) + + topic.reload + expect(topic.posts.count).to eq(1) + end + + it "should not generate a notification for auto-message" do + post = create_post PostAction.act(moderator, post, PostActionType.types[:spam], message: "WAT") PostAlerter.expects(:post_created).never