diff --git a/app/mailers/admin_mailer.rb b/app/mailers/admin_mailer.rb index 8dd7b6e59f..72a2c2e64e 100644 --- a/app/mailers/admin_mailer.rb +++ b/app/mailers/admin_mailer.rb @@ -56,9 +56,11 @@ class AdminMailer < ApplicationMailer def new_critical_software_updates @software_updates = SoftwareUpdate.where(urgent: true).to_a.sort_by(&:gem_version) - headers['Priority'] = 'urgent' - headers['X-Priority'] = '1' - headers['Importance'] = 'high' + headers( + 'Importance' => 'high', + 'Priority' => 'urgent', + 'X-Priority' => '1' + ) locale_for_account(@me) do mail subject: default_i18n_subject(instance: @instance) diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb index 35f0b5fee1..9a209aa77b 100644 --- a/app/mailers/application_mailer.rb +++ b/app/mailers/application_mailer.rb @@ -16,8 +16,10 @@ class ApplicationMailer < ActionMailer::Base end def set_autoreply_headers! - headers['Precedence'] = 'list' - headers['X-Auto-Response-Suppress'] = 'All' - headers['Auto-Submitted'] = 'auto-generated' + headers( + 'Auto-Submitted' => 'auto-generated', + 'Precedence' => 'list', + 'X-Auto-Response-Suppress' => 'All' + ) end end diff --git a/app/mailers/notification_mailer.rb b/app/mailers/notification_mailer.rb index 4eb38ec340..6b21b4bedd 100644 --- a/app/mailers/notification_mailer.rb +++ b/app/mailers/notification_mailer.rb @@ -6,7 +6,10 @@ class NotificationMailer < ApplicationMailer :routing before_action :process_params - before_action :set_status, only: [:mention, :favourite, :reblog] + with_options only: %i(mention favourite reblog) do + before_action :set_status + after_action :thread_by_conversation! + end before_action :set_account, only: [:follow, :favourite, :reblog, :follow_request] after_action :set_list_headers! @@ -18,7 +21,6 @@ class NotificationMailer < ApplicationMailer return unless @user.functional? && @status.present? locale_for_account(@me) do - thread_by_conversation(@status.conversation) mail subject: default_i18n_subject(name: @status.account.acct) end end @@ -35,7 +37,6 @@ class NotificationMailer < ApplicationMailer return unless @user.functional? && @status.present? locale_for_account(@me) do - thread_by_conversation(@status.conversation) mail subject: default_i18n_subject(name: @account.acct) end end @@ -44,7 +45,6 @@ class NotificationMailer < ApplicationMailer return unless @user.functional? && @status.present? locale_for_account(@me) do - thread_by_conversation(@status.conversation) mail subject: default_i18n_subject(name: @account.acct) end end @@ -76,17 +76,21 @@ class NotificationMailer < ApplicationMailer end def set_list_headers! - headers['List-ID'] = "<#{@type}.#{@me.username}.#{Rails.configuration.x.local_domain}>" - headers['List-Unsubscribe'] = "<#{@unsubscribe_url}>" - headers['List-Unsubscribe-Post'] = 'List-Unsubscribe=One-Click' + headers( + 'List-ID' => "<#{@type}.#{@me.username}.#{Rails.configuration.x.local_domain}>", + 'List-Unsubscribe-Post' => 'List-Unsubscribe=One-Click', + 'List-Unsubscribe' => "<#{@unsubscribe_url}>" + ) end - def thread_by_conversation(conversation) - return if conversation.nil? + def thread_by_conversation! + return if @status.conversation.nil? - msg_id = "" + conversation_message_id = "" - headers['In-Reply-To'] = msg_id - headers['References'] = msg_id + headers( + 'In-Reply-To' => conversation_message_id, + 'References' => conversation_message_id + ) end end