2020-09-19 04:49:15 +01:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class IntroduceAccountProWorker
|
|
|
|
include Sidekiq::Worker
|
|
|
|
|
|
|
|
sidekiq_options queue: 'mailers', retry: 2
|
|
|
|
|
|
|
|
attr_reader :user
|
|
|
|
|
|
|
|
def perform(acct_id, date_range)
|
|
|
|
@acct = Account.find(acct_id)
|
|
|
|
deliver_email(date_range)
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def deliver_email(date_range)
|
2021-02-01 08:43:56 +00:00
|
|
|
return if @acct.nil? or @acct.user.nil?
|
2020-09-19 04:49:15 +01:00
|
|
|
UserMailer.introduce_pro(@acct.user, date_range).deliver_now!
|
|
|
|
@acct.user.touch(:last_emailed_at)
|
|
|
|
end
|
|
|
|
end
|