2024-04-29 00:17:15 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2023-01-23 14:56:05 +01:00
|
|
|
module BalancedDeliveryConcern
|
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
|
|
|
included do
|
2023-10-18 07:10:26 +02:00
|
|
|
before_action :add_delivery_method, if: :forced_delivery_provider?
|
2023-01-23 14:56:05 +01:00
|
|
|
|
2023-10-18 07:10:26 +02:00
|
|
|
def critical_email?
|
|
|
|
self.class.critical_email?(action_name)
|
2023-01-23 14:56:05 +01:00
|
|
|
end
|
|
|
|
|
2024-05-29 09:52:54 +02:00
|
|
|
def bypass_unverified_mail_protection!
|
|
|
|
headers[BalancerDeliveryMethod::BYPASS_UNVERIFIED_MAIL_PROTECTION] = true
|
|
|
|
end
|
|
|
|
|
2023-10-18 07:10:26 +02:00
|
|
|
private
|
|
|
|
|
|
|
|
def forced_delivery_provider?
|
|
|
|
SafeMailer.forced_delivery_method.present? && critical_email?
|
2023-01-23 14:56:05 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def add_delivery_method
|
|
|
|
headers[BalancerDeliveryMethod::FORCE_DELIVERY_METHOD_HEADER] = SafeMailer.forced_delivery_method
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|