How to check that an email is already enqueued, Im using active job:
ofert_approved_notifier = Notifier.ofert_approved(@ofert.user, @ofert)
if ofert_approved_notifier.deliver_later(wait: 1.hour)
puts "Email ofert_approved sent successfully"
else
puts "Email ofert_approved could not be sent"
end
As you can see above, Im sending an email to @ofert.user
and it is delayed 1 hour before being sent, the above code is in a controller action, I want to check if the email is already enqueued for @ofert.user
, I do not want to send the same email to the same user if it is already in the queue.
Is there a way I can check that?. Thanks
Delayed::Job is an ActiveRecord object so you can check if a records exists.
Delayed::Job.where(...)
Look at the structure of stored records and find out how your email workers are stored and how to find them by email. Good luck!