Use headers
shorthand in mailers (#31956)
This commit is contained in:
parent
6801afa12f
commit
2946a9286b
3 changed files with 26 additions and 18 deletions
|
@ -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-#{conversation.id}.#{conversation.created_at.strftime('%Y-%m-%d')}@#{Rails.configuration.x.local_domain}>"
|
||||
conversation_message_id = "<conversation-#{@status.conversation.id}.#{@status.conversation.created_at.to_date}@#{Rails.configuration.x.local_domain}>"
|
||||
|
||||
headers['In-Reply-To'] = msg_id
|
||||
headers['References'] = msg_id
|
||||
headers(
|
||||
'In-Reply-To' => conversation_message_id,
|
||||
'References' => conversation_message_id
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue