mirror of
https://github.com/discourse/discourse.git
synced 2024-12-12 02:53:45 +08:00
c1ea63bdc1
Conversely, if a user is deactivated the reviewable should automatically be rejected. Before this fix, if a user was not active they'd still show in the review queue but without an "Approve" button which was confusing.
30 lines
797 B
Ruby
30 lines
797 B
Ruby
module Jobs
|
|
|
|
class InvalidateInactiveAdmins < Jobs::Scheduled
|
|
every 1.day
|
|
|
|
def execute(_)
|
|
return if SiteSetting.invalidate_inactive_admin_email_after_days == 0
|
|
|
|
User.human_users
|
|
.where(admin: true)
|
|
.where(active: true)
|
|
.where('last_seen_at < ?', SiteSetting.invalidate_inactive_admin_email_after_days.days.ago)
|
|
.each do |user|
|
|
|
|
User.transaction do
|
|
user.deactivate(Discourse.system_user)
|
|
user.email_tokens.update_all(confirmed: false, expired: true)
|
|
|
|
Discourse.authenticators.each do |authenticator|
|
|
if authenticator.can_revoke? && authenticator.description_for_user(user).present?
|
|
authenticator.revoke(user)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
end
|