Class: ContactMailerWorker

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

Instance Method Summary collapse

Instance Method Details

#perform(contact_id) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
# File 'app/workers/contact_mailer_worker.rb', line 4

def perform(contact_id)
  return unless (contact = Contact.find(contact_id))

  if contact.email_sent_at.blank?
    ContactMailer.contact_email(contact).deliver_now
    contact.update_column :email_sent_at, Time.current
    Sidekiq.logger.info "Sent email to #{contact.email}"
  else
    Sidekiq.logger.info "Skipping email to #{contact.email}"
  end
end