From eff45f98d60e888f6aa8e6f6c0c57dcb65169495 Mon Sep 17 00:00:00 2001 From: Shujat Khalid Date: Wed, 17 Jul 2024 09:57:34 +0100 Subject: [PATCH] add class which extends the behaviour of MailDeliveryJob by recording information in the MailDeliveryFailure table --- app/jobs/log_mail_delivery_failure_job.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 app/jobs/log_mail_delivery_failure_job.rb diff --git a/app/jobs/log_mail_delivery_failure_job.rb b/app/jobs/log_mail_delivery_failure_job.rb new file mode 100644 index 000000000..e69b7bf4b --- /dev/null +++ b/app/jobs/log_mail_delivery_failure_job.rb @@ -0,0 +1,18 @@ +class LogMailDeliveryFailureJob < ActionMailer::MailDeliveryJob + def perform(*args) + super + rescue => e + + record_failure(*args) + end + + private + + def record_failure(*args) + MailDeliveryFailure.create( + email_address: + mailer_class: + mailer_action_method: + ) + end + end