Class: PersonalAccessTokens::ExpiredNotificationWorker

Inherits:
Object
  • Object
show all
Includes:
ApplicationWorker, CronjobQueue
Defined in:
app/workers/personal_access_tokens/expired_notification_worker.rb

Overview

rubocop:disable Scalability/IdempotentWorker

Constant Summary

Constants included from ApplicationWorker

ApplicationWorker::LOGGING_EXTRA_KEY, ApplicationWorker::SAFE_PUSH_BULK_LIMIT

Constants included from WorkerAttributes

WorkerAttributes::DEFAULT_DATA_CONSISTENCY, WorkerAttributes::NAMESPACE_WEIGHTS, WorkerAttributes::VALID_DATA_CONSISTENCIES, WorkerAttributes::VALID_RESOURCE_BOUNDARIES, WorkerAttributes::VALID_URGENCIES

Instance Method Summary collapse

Methods included from Gitlab::SidekiqVersioning::Worker

#job_version

Methods included from WorkerContext

#with_context

Instance Method Details

#perform(*args) ⇒ Object


13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/workers/personal_access_tokens/expired_notification_worker.rb', line 13

def perform(*args)
  notification_service = NotificationService.new

  User.with_personal_access_tokens_expired_today.find_each do |user|
    with_context(user: user) do
      Gitlab::AppLogger.info "#{self.class}: Notifying User #{user.id} about an expired token"

      notification_service.access_token_expired(user)

      user.personal_access_tokens.without_impersonation.expired_today_and_not_notified.update_all(after_expiry_notification_delivered: true)
    end
  end
end