Welcome to mirror list, hosted at ThFree Co, Russian Federation.

custom_email_verification_cleanup_worker.rb « service_desk « workers « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 6434b9b09bb580b444a6efc7c8e00c257c7e792d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# frozen_string_literal: true

module ServiceDesk
  # Marks custom email verifications as failed when
  # verification has started and timeframe to ingest
  # the verification email has closed.
  #
  # This ensures we can finish the verification process and send verification result emails
  # even when we did not receive any verification email.
  class CustomEmailVerificationCleanupWorker
    include ApplicationWorker
    include CronjobQueue

    idempotent!

    data_consistency :sticky
    feature_category :service_desk

    def perform
      # Limit ensures we have 50ms per verification before another job gets scheduled.
      collection = CustomEmailVerification.started.overdue.limit(2_400)

      collection.find_each do |verification|
        with_context(project: verification.project) do
          CustomEmailVerifications::UpdateService.new(
            project: verification.project,
            current_user: nil,
            params: {
              mail: nil
            }
          ).execute
        end
      end
    end
  end
end