diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-21 02:50:22 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-21 02:50:22 +0300 |
commit | 9dc93a4519d9d5d7be48ff274127136236a3adb3 (patch) | |
tree | 70467ae3692a0e35e5ea56bcb803eb512a10bedb /app/workers/ssh_keys | |
parent | 4b0f34b6d759d6299322b3a54453e930c6121ff0 (diff) |
Add latest changes from gitlab-org/gitlab@13-11-stable-eev13.11.0-rc43
Diffstat (limited to 'app/workers/ssh_keys')
-rw-r--r-- | app/workers/ssh_keys/expired_notification_worker.rb | 25 | ||||
-rw-r--r-- | app/workers/ssh_keys/expiring_soon_notification_worker.rb | 25 |
2 files changed, 50 insertions, 0 deletions
diff --git a/app/workers/ssh_keys/expired_notification_worker.rb b/app/workers/ssh_keys/expired_notification_worker.rb new file mode 100644 index 00000000000..ab6d1998773 --- /dev/null +++ b/app/workers/ssh_keys/expired_notification_worker.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +module SshKeys + class ExpiredNotificationWorker + include ApplicationWorker + include CronjobQueue + + feature_category :compliance_management + idempotent! + + def perform + return unless ::Feature.enabled?(:ssh_key_expiration_email_notification, default_enabled: :yaml) + + User.with_ssh_key_expired_today.find_each do |user| + with_context(user: user) do + Gitlab::AppLogger.info "#{self.class}: Notifying User #{user.id} about expired ssh key(s)" + + keys = user.expired_today_and_unnotified_keys + + Keys::ExpiryNotificationService.new(user, { keys: keys, expiring_soon: false }).execute + end + end + end + end +end diff --git a/app/workers/ssh_keys/expiring_soon_notification_worker.rb b/app/workers/ssh_keys/expiring_soon_notification_worker.rb new file mode 100644 index 00000000000..3214cd7a242 --- /dev/null +++ b/app/workers/ssh_keys/expiring_soon_notification_worker.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +module SshKeys + class ExpiringSoonNotificationWorker + include ApplicationWorker + include CronjobQueue + + feature_category :compliance_management + idempotent! + + def perform + return unless ::Feature.enabled?(:ssh_key_expiration_email_notification, default_enabled: :yaml) + + User.with_ssh_key_expiring_soon.find_each do |user| + with_context(user: user) do + Gitlab::AppLogger.info "#{self.class}: Notifying User #{user.id} about expiring soon ssh key(s)" + + keys = user.expiring_soon_and_unnotified_keys + + Keys::ExpiryNotificationService.new(user, { keys: keys, expiring_soon: true }).execute + end + end + end + end +end |