FEATURE: Add message to log when admins are automatically deactivated
This commit is contained in:
parent
25fd2b544a
commit
a9d0d55817
|
@ -22,6 +22,9 @@ module Jobs
|
||||||
user.deactivate(Discourse.system_user)
|
user.deactivate(Discourse.system_user)
|
||||||
user.email_tokens.update_all(confirmed: false, expired: true)
|
user.email_tokens.update_all(confirmed: false, expired: true)
|
||||||
|
|
||||||
|
reason = I18n.t("user.deactivated_by_inactivity", count: SiteSetting.invalidate_inactive_admin_email_after_days)
|
||||||
|
StaffActionLogger.new(Discourse.system_user).log_user_deactivate(user, reason)
|
||||||
|
|
||||||
Discourse.authenticators.each do |authenticator|
|
Discourse.authenticators.each do |authenticator|
|
||||||
if authenticator.can_revoke? && authenticator.description_for_user(user).present?
|
if authenticator.can_revoke? && authenticator.description_for_user(user).present?
|
||||||
authenticator.revoke(user)
|
authenticator.revoke(user)
|
||||||
|
|
|
@ -2377,6 +2377,9 @@ en:
|
||||||
user:
|
user:
|
||||||
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"
|
||||||
|
deactivated_by_inactivity:
|
||||||
|
one: "Automatically deactivated after %{count} day of inactivity"
|
||||||
|
other: "Automatically deactivated after %{count} days of inactivity"
|
||||||
activated_by_staff: "Activated by staff"
|
activated_by_staff: "Activated by staff"
|
||||||
new_user_typed_too_fast: "New user typed too fast"
|
new_user_typed_too_fast: "New user typed too fast"
|
||||||
content_matches_auto_block_regex: "Content matches auto block regex"
|
content_matches_auto_block_regex: "Content matches auto block regex"
|
||||||
|
|
|
@ -29,7 +29,16 @@ describe Jobs::InvalidateInactiveAdmins do
|
||||||
expect(not_seen_admin.reload.email_tokens.where(confirmed: true).exists?).to eq(false)
|
expect(not_seen_admin.reload.email_tokens.where(confirmed: true).exists?).to eq(false)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'makes the user as not active' do
|
it 'makes the user as not active and logs the action' do
|
||||||
|
subject
|
||||||
|
expect(not_seen_admin.reload.active).to eq(false)
|
||||||
|
|
||||||
|
log = UserHistory.last
|
||||||
|
expect(log.target_user_id).to eq(not_seen_admin.id)
|
||||||
|
expect(log.action).to eq(UserHistory.actions[:deactivate_user])
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'adds a staff log' do
|
||||||
subject
|
subject
|
||||||
expect(not_seen_admin.reload.active).to eq(false)
|
expect(not_seen_admin.reload.active).to eq(false)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue