2015-12-07 07:23:23 -05:00
|
|
|
class BuildEmailWorker
|
|
|
|
include Sidekiq::Worker
|
2016-10-21 12:13:41 -04:00
|
|
|
include BuildQueue
|
2015-12-07 07:23:23 -05:00
|
|
|
|
|
|
|
def perform(build_id, recipients, push_data)
|
2015-12-09 10:31:42 -05:00
|
|
|
recipients.each do |recipient|
|
2015-12-07 07:23:23 -05:00
|
|
|
begin
|
|
|
|
case push_data['build_status']
|
|
|
|
when 'success'
|
|
|
|
Notify.build_success_email(build_id, recipient).deliver_now
|
|
|
|
when 'failed'
|
|
|
|
Notify.build_fail_email(build_id, recipient).deliver_now
|
|
|
|
end
|
|
|
|
# These are input errors and won't be corrected even if Sidekiq retries
|
|
|
|
rescue Net::SMTPFatalError, Net::SMTPSyntaxError => e
|
|
|
|
logger.info("Failed to send e-mail for project '#{push_data['project_name']}' to #{recipient}: #{e}")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|