Add notify_mods_when_user_blocked site setting to control whether moderators get a message when someone is automatically blocked

This commit is contained in:
Neil Lalonde 2013-08-19 12:00:48 -04:00
parent 8431a5c1f5
commit 7eaedb84e1
4 changed files with 9 additions and 2 deletions

View File

@ -67,6 +67,7 @@ class SiteSetting < ActiveRecord::Base
setting(:num_flags_to_block_new_user, 3)
setting(:num_users_to_block_new_user, 3)
setting(:notify_mods_when_user_blocked, true)
# used mainly for dev, force hostname for Discourse.base_url
# You would usually use multisite for this

View File

@ -48,7 +48,7 @@ class SpamRulesEnforcer
def punish_user
Post.transaction do
if UserBlocker.block(@user, nil, {message: :too_many_spam_flags})
if UserBlocker.block(@user, nil, {message: :too_many_spam_flags}) and SiteSetting.notify_mods_when_user_blocked
GroupMessage.create(Group[:moderators].name, :user_automatically_blocked, {user: @user, limit_once_per: false})
end
end

View File

@ -505,7 +505,7 @@ en:
cooldown_minutes_after_hiding_posts: "Number of minutes a user must wait before they can edit a post hidden via flagging"
num_flags_to_block_new_user: "If a new user's posts get this many spam flags from (n) different users, hide all their posts and prevent future posting. 0 disables this feature."
num_users_to_block_new_user: "If a new user's posts get (x) spam flags from this many different users, hide all their posts and prevent future posting. 0 disables this feature."
notify_mods_when_user_blocked: "If a user is automatically blocked, send a message to all moderators."
traditional_markdown_linebreaks: "Use traditional linebreaks in Markdown, which require two trailing spaces for a linebreak"
post_undo_action_window_mins: "Number of seconds users are allowed to reverse actions on a post (like, flag, etc)"

View File

@ -128,6 +128,12 @@ describe SpamRulesEnforcer do
end
subject.punish_user
end
it "doesn't send a pm to moderators if notify_mods_when_user_blocked is false" do
SiteSetting.stubs(:notify_mods_when_user_blocked).returns(false)
GroupMessage.expects(:create).never
subject.punish_user
end
end
context 'user is already blocked' do