joshmn / caffeinate

A Rails engine for drip campaigns/scheduled sequences and periodical support. Works with ActionMailer, and other things.
https://caffeinate.email
MIT License
345 stars 13 forks source link

before_drip is not working #12

Closed AvidRambo closed 2 years ago

AvidRambo commented 2 years ago

Our mailing queue is getting looped when a user is deleted. Looks like the mailer action still gets evaluated, I checked if the mailing was returning nil and indeed it does.

I could check if the user exists in the mailer but it defeats the purpose of the library.

undefined methodset_login_bypass_token' for nil:NilClass`

before_drip do |_drip, mailing|
  if mailing.user.nil?
    mailing.subscription.end!("User not found")
    throw(:abort)
  end
end
def job_available_notification(mailing)
  @job = mailing.subscriber
  @action_url = job_url(@job, login_bypass_token: @user.set_login_bypass_token)

  mail(to: @user.email, subject: "Nuevo trabajo disponible")
end