Class: BuildEmailWorker

Inherits:
Object
  • Object
show all
Includes:
Sidekiq::Worker
Defined in:
app/workers/build_email_worker.rb

Instance Method Summary collapse

Instance Method Details

#perform(build_id, recipients, push_data) ⇒ Object


4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'app/workers/build_email_worker.rb', line 4

def perform(build_id, recipients, push_data)
  recipients.each do |recipient|
    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