From 19dedd7cfd9a6d61e136519ede4447d7ec0e6e60 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Tue, 24 Sep 2024 09:16:31 -0400 Subject: [PATCH] Set important mailer headers with `after_action` callback (#32057) --- app/mailers/admin_mailer.rb | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/app/mailers/admin_mailer.rb b/app/mailers/admin_mailer.rb index 72a2c2e64..fffbbb3c6 100644 --- a/app/mailers/admin_mailer.rb +++ b/app/mailers/admin_mailer.rb @@ -9,6 +9,8 @@ class AdminMailer < ApplicationMailer before_action :process_params before_action :set_instance + after_action :set_important_headers!, only: :new_critical_software_updates + default to: -> { @me.user_email } def new_report(report) @@ -56,12 +58,6 @@ class AdminMailer < ApplicationMailer def new_critical_software_updates @software_updates = SoftwareUpdate.where(urgent: true).to_a.sort_by(&:gem_version) - headers( - 'Importance' => 'high', - 'Priority' => 'urgent', - 'X-Priority' => '1' - ) - locale_for_account(@me) do mail subject: default_i18n_subject(instance: @instance) end @@ -82,4 +78,12 @@ class AdminMailer < ApplicationMailer def set_instance @instance = Rails.configuration.x.local_domain end + + def set_important_headers! + headers( + 'Importance' => 'high', + 'Priority' => 'urgent', + 'X-Priority' => '1' + ) + end end