FEATURE: log reason staff auto blocks a user

This commit is contained in:
Sam 2017-03-10 15:45:48 -05:00
parent f13367cecd
commit 16593ae8bf
3 changed files with 7 additions and 3 deletions

View File

@ -20,7 +20,7 @@ class UserBlocker
message_type = @opts[:message] || :blocked_by_staff message_type = @opts[:message] || :blocked_by_staff
post = SystemMessage.create(@user, message_type) post = SystemMessage.create(@user, message_type)
if post && @by_user if post && @by_user
StaffActionLogger.new(@by_user).log_block_user(@user, {context: "#{message_type}: '#{post.topic&.title rescue ''}'"}) StaffActionLogger.new(@by_user).log_block_user(@user, {context: "#{message_type}: '#{post.topic&.title rescue ''}' #{@opts[:reason]}"})
end end
end end
else else

View File

@ -1640,6 +1640,8 @@ en:
deactivated: "Was deactivated due to too many bounced emails to '%{email}'." deactivated: "Was deactivated due to too many bounced emails to '%{email}'."
deactivated_by_staff: "Deactivated by staff" deactivated_by_staff: "Deactivated by staff"
activated_by_staff: "Activated by staff" activated_by_staff: "Activated by staff"
new_user_typed_too_fast: "New user typed too fast"
content_matches_auto_block_regex: "Content matches auto block regex"
username: username:
short: "must be at least %{min} characters" short: "must be at least %{min} characters"
long: "must be no more than %{max} characters" long: "must be no more than %{max} characters"

View File

@ -104,8 +104,10 @@ class NewPostManager
result = manager.enqueue('default') result = manager.enqueue('default')
if is_fast_typer?(manager) || matches_auto_block_regex?(manager) if is_fast_typer?(manager)
UserBlocker.block(manager.user, Discourse.system_user, keep_posts: true) UserBlocker.block(manager.user, Discourse.system_user, keep_posts: true, reason: I18n.t("user.new_user_typed_too_fast"))
elsif matches_auto_block_regex?(manager)
UserBlocker.block(manager.user, Discourse.system_user, keep_posts: true, reason: I18n.t("user.content_matches_auto_block_regex"))
end end
result result