Add more info in staff action logs for blocking a user, and add logging for lock trust level, activate, and deactive user
This commit is contained in:
parent
0303047446
commit
fc0a0a76a4
|
@ -46,6 +46,7 @@ class Admin::UsersController < Admin::AdminController
|
||||||
def delete_all_posts
|
def delete_all_posts
|
||||||
@user = User.find_by(id: params[:user_id])
|
@user = User.find_by(id: params[:user_id])
|
||||||
@user.delete_all_posts!(guardian)
|
@user.delete_all_posts!(guardian)
|
||||||
|
# staff action logs will have an entry for each post
|
||||||
render nothing: true
|
render nothing: true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -182,6 +183,8 @@ class Admin::UsersController < Admin::AdminController
|
||||||
@user.trust_level_locked = new_lock == "true"
|
@user.trust_level_locked = new_lock == "true"
|
||||||
@user.save
|
@user.save
|
||||||
|
|
||||||
|
StaffActionLogger.new(current_user).log_lock_trust_level(@user)
|
||||||
|
|
||||||
unless @user.trust_level_locked
|
unless @user.trust_level_locked
|
||||||
p = Promotion.new(@user)
|
p = Promotion.new(@user)
|
||||||
2.times{ p.review }
|
2.times{ p.review }
|
||||||
|
@ -210,12 +213,14 @@ class Admin::UsersController < Admin::AdminController
|
||||||
def activate
|
def activate
|
||||||
guardian.ensure_can_activate!(@user)
|
guardian.ensure_can_activate!(@user)
|
||||||
@user.activate
|
@user.activate
|
||||||
|
StaffActionLogger.new(current_user).log_user_activate(@user, I18n.t('user.activated_by_staff'))
|
||||||
render json: success_json
|
render json: success_json
|
||||||
end
|
end
|
||||||
|
|
||||||
def deactivate
|
def deactivate
|
||||||
guardian.ensure_can_deactivate!(@user)
|
guardian.ensure_can_deactivate!(@user)
|
||||||
@user.deactivate
|
@user.deactivate
|
||||||
|
StaffActionLogger.new(current_user).log_user_deactivate(@user, I18n.t('user.deactivated_by_staff'))
|
||||||
refresh_browser @user
|
refresh_browser @user
|
||||||
render nothing: true
|
render nothing: true
|
||||||
end
|
end
|
||||||
|
|
|
@ -55,7 +55,10 @@ class UserHistory < ActiveRecord::Base
|
||||||
rate_limited_like: 37, # not used anymore
|
rate_limited_like: 37, # not used anymore
|
||||||
revoke_email: 38,
|
revoke_email: 38,
|
||||||
deactivate_user: 39,
|
deactivate_user: 39,
|
||||||
wizard_step: 40
|
wizard_step: 40,
|
||||||
|
lock_trust_level: 41,
|
||||||
|
unlock_trust_level: 42,
|
||||||
|
activate_user: 43
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -91,7 +94,10 @@ class UserHistory < ActiveRecord::Base
|
||||||
:revoke_moderation,
|
:revoke_moderation,
|
||||||
:backup_operation,
|
:backup_operation,
|
||||||
:revoke_email,
|
:revoke_email,
|
||||||
:deactivate_user]
|
:deactivate_user,
|
||||||
|
:lock_trust_level,
|
||||||
|
:unlock_trust_level,
|
||||||
|
:activate_user]
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.staff_action_ids
|
def self.staff_action_ids
|
||||||
|
|
|
@ -96,6 +96,14 @@ class StaffActionLogger
|
||||||
}))
|
}))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def log_lock_trust_level(user, opts={})
|
||||||
|
raise Discourse::InvalidParameters.new(:user) unless user && user.is_a?(User)
|
||||||
|
UserHistory.create!( params(opts).merge({
|
||||||
|
action: UserHistory.actions[user.trust_level_locked ? :lock_trust_level : :unlock_trust_level],
|
||||||
|
target_user_id: user.id
|
||||||
|
}))
|
||||||
|
end
|
||||||
|
|
||||||
def log_site_setting_change(setting_name, previous_value, new_value, opts={})
|
def log_site_setting_change(setting_name, previous_value, new_value, opts={})
|
||||||
raise Discourse::InvalidParameters.new(:setting_name) unless setting_name.present? && SiteSetting.respond_to?(setting_name)
|
raise Discourse::InvalidParameters.new(:setting_name) unless setting_name.present? && SiteSetting.respond_to?(setting_name)
|
||||||
UserHistory.create( params(opts).merge({
|
UserHistory.create( params(opts).merge({
|
||||||
|
@ -353,6 +361,15 @@ class StaffActionLogger
|
||||||
}))
|
}))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def log_user_activate(user, reason, opts={})
|
||||||
|
raise Discourse::InvalidParameters.new(:user) unless user
|
||||||
|
UserHistory.create(params(opts).merge({
|
||||||
|
action: UserHistory.actions[:activate_user],
|
||||||
|
target_user_id: user.id,
|
||||||
|
details: reason
|
||||||
|
}))
|
||||||
|
end
|
||||||
|
|
||||||
def log_wizard_step(step, opts={})
|
def log_wizard_step(step, opts={})
|
||||||
raise Discourse::InvalidParameters.new(:step) unless step
|
raise Discourse::InvalidParameters.new(:step) unless step
|
||||||
UserHistory.create(params(opts).merge({
|
UserHistory.create(params(opts).merge({
|
||||||
|
|
|
@ -17,8 +17,11 @@ class UserBlocker
|
||||||
unless @user.blocked?
|
unless @user.blocked?
|
||||||
@user.blocked = true
|
@user.blocked = true
|
||||||
if @user.save
|
if @user.save
|
||||||
SystemMessage.create(@user, @opts[:message] || :blocked_by_staff)
|
message_type = @opts[:message] || :blocked_by_staff
|
||||||
StaffActionLogger.new(@by_user).log_block_user(@user) if @by_user
|
post = SystemMessage.create(@user, message_type)
|
||||||
|
if post && @by_user
|
||||||
|
StaffActionLogger.new(@by_user).log_block_user(@user, {context: "#{message_type}: '#{post.topic&.title rescue ''}'"})
|
||||||
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
false
|
false
|
||||||
|
|
|
@ -2914,6 +2914,10 @@ en:
|
||||||
deleted_tag: "deleted tag"
|
deleted_tag: "deleted tag"
|
||||||
renamed_tag: "renamed tag"
|
renamed_tag: "renamed tag"
|
||||||
revoke_email: "revoke email"
|
revoke_email: "revoke email"
|
||||||
|
lock_trust_level: "lock trust level"
|
||||||
|
unlock_trust_level: "unlock trust level"
|
||||||
|
activate_user: "activate user"
|
||||||
|
deactivate_user: "deactivate user"
|
||||||
screened_emails:
|
screened_emails:
|
||||||
title: "Screened Emails"
|
title: "Screened Emails"
|
||||||
description: "When someone tries to create a new account, the following email addresses will be checked and the registration will be blocked, or some other action performed."
|
description: "When someone tries to create a new account, the following email addresses will be checked and the registration will be blocked, or some other action performed."
|
||||||
|
|
|
@ -1615,6 +1615,8 @@ en:
|
||||||
user:
|
user:
|
||||||
no_accounts_associated: "No accounts associated"
|
no_accounts_associated: "No accounts associated"
|
||||||
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"
|
||||||
|
activated_by_staff: "Activated by staff"
|
||||||
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"
|
||||||
|
|
Loading…
Reference in New Issue