Browse Source

CLDC-4280: send notify emails in real time in all environments to avoid auth/time skew errors

pull/3262/head
Nat Dean-Lewis 1 month ago
parent
commit
b669183b26
  1. 10
      app/mailers/devise_notify_mailer.rb
  2. 10
      app/mailers/notify_mailer.rb

10
app/mailers/devise_notify_mailer.rb

@ -8,11 +8,21 @@ class DeviseNotifyMailer < Devise::Mailer
def send_email(email_address, template_id, personalisation) def send_email(email_address, template_id, personalisation)
return true if intercept_send?(email_address) return true if intercept_send?(email_address)
if defined?(Timecop)
Timecop.return do
notify_client.send_email( notify_client.send_email(
email_address:, email_address:,
template_id:, template_id:,
personalisation:, personalisation:,
) )
end
else
notify_client.send_email(
email_address:,
template_id:,
personalisation:,
)
end
rescue Notifications::Client::BadRequestError => e rescue Notifications::Client::BadRequestError => e
Sentry.capture_exception(e) Sentry.capture_exception(e)

10
app/mailers/notify_mailer.rb

@ -8,12 +8,22 @@ class NotifyMailer < ApplicationMailer
def send_email(email, template_id, personalisation) def send_email(email, template_id, personalisation)
return true if intercept_send?(email) return true if intercept_send?(email)
if defined?(Timecop)
Timecop.return do
notify_client.send_email( notify_client.send_email(
email_address: email, email_address: email,
template_id:, template_id:,
personalisation:, personalisation:,
) )
end end
else
notify_client.send_email(
email_address: email,
template_id:,
personalisation:,
)
end
end
def personalisation(record, token, url, username: false) def personalisation(record, token, url, username: false)
{ {

Loading…
Cancel
Save