Class: ContactSlackWorker

Inherits:
Object
  • Object
show all
Includes:
Sidekiq::Worker
Defined in:
app/workers/contact_slack_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_slack_worker.rb', line 4

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

  if contact.slack_notified_at.blank?
    SlackNotifier.new.notify_new_contact(contact)
    contact.update_column :slack_notified_at, Time.current
    Sidekiq.logger.info "Slack notification sent: #{contact.email}"
  else
    Sidekiq.logger.info "Slack notification skipped: #{contact.email}"
  end
end