demarches-normaliennes/app/mailers/concerns/balanced_delivery_concern.rb

28 lines
666 B
Ruby
Raw Normal View History

# frozen_string_literal: true
module BalancedDeliveryConcern
extend ActiveSupport::Concern
included do
before_action :add_delivery_method, if: :forced_delivery_provider?
def critical_email?
self.class.critical_email?(action_name)
end
2024-05-29 09:52:54 +02:00
def bypass_unverified_mail_protection!
headers[BalancerDeliveryMethod::BYPASS_UNVERIFIED_MAIL_PROTECTION] = true
end
private
def forced_delivery_provider?
SafeMailer.forced_delivery_method.present? && critical_email?
end
def add_delivery_method
headers[BalancerDeliveryMethod::FORCE_DELIVERY_METHOD_HEADER] = SafeMailer.forced_delivery_method
end
end
end