2016-09-13 07:09:53 -04:00
|
|
|
module Ci
|
2016-09-14 12:01:26 -04:00
|
|
|
class SendPipelineNotificationService
|
2016-09-13 07:09:53 -04:00
|
|
|
attr_reader :pipeline
|
|
|
|
|
|
|
|
def initialize(new_pipeline)
|
|
|
|
@pipeline = new_pipeline
|
|
|
|
end
|
|
|
|
|
2016-09-14 07:34:24 -04:00
|
|
|
def execute(recipients)
|
|
|
|
email_template = "pipeline_#{pipeline.status}_email"
|
|
|
|
|
|
|
|
return unless Notify.respond_to?(email_template)
|
|
|
|
|
|
|
|
recipients.each do |to|
|
|
|
|
Notify.public_send(email_template, pipeline, to).deliver_later
|
|
|
|
end
|
2016-09-13 07:09:53 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|