debian-mirror-gitlab/app/workers/auto_devops/disable_worker.rb

44 lines
1,015 B
Ruby
Raw Normal View History

2018-11-20 20:47:30 +05:30
# frozen_string_literal: true
module AutoDevops
2020-04-08 14:13:33 +05:30
class DisableWorker # rubocop:disable Scalability/IdempotentWorker
2018-11-20 20:47:30 +05:30
include ApplicationWorker
2021-06-08 01:23:25 +05:30
2021-10-27 15:23:28 +05:30
data_consistency :always
2021-06-08 01:23:25 +05:30
sidekiq_options retry: 3
2018-11-20 20:47:30 +05:30
include AutoDevopsQueue
def perform(pipeline_id)
pipeline = Ci::Pipeline.find(pipeline_id)
project = pipeline.project
send_notification_email(pipeline, project) if disable_service(project).execute
end
private
def disable_service(project)
Projects::AutoDevops::DisableService.new(project)
end
def send_notification_email(pipeline, project)
recipients = email_receivers_for(pipeline, project)
return unless recipients.any?
NotificationService.new.autodevops_disabled(pipeline, recipients)
end
def email_receivers_for(pipeline, project)
recipients = [pipeline.user&.email]
2022-04-04 11:22:00 +05:30
if project.personal?
recipients << project.owners.map(&:email)
end
recipients.flatten.uniq.compact
2018-11-20 20:47:30 +05:30
end
end
end