Thread toot notification mails by conversation (#5061)

* Thread toot notification mails by conversation

* Make codeclimate happy and avoid potential mis-threading
lolsob-rspec
ThibG 2017-09-24 11:19:42 +02:00 committed by Eugen Rochko
parent 7e6322863c
commit 2338b5954c
1 changed files with 12 additions and 0 deletions

View File

@ -8,6 +8,7 @@ class NotificationMailer < ApplicationMailer
@status = notification.target_status @status = notification.target_status
locale_for_account(@me) do locale_for_account(@me) do
thread_by_conversation(@status.conversation)
mail to: @me.user.email, subject: I18n.t('notification_mailer.mention.subject', name: @status.account.acct) mail to: @me.user.email, subject: I18n.t('notification_mailer.mention.subject', name: @status.account.acct)
end end
end end
@ -27,6 +28,7 @@ class NotificationMailer < ApplicationMailer
@status = notification.target_status @status = notification.target_status
locale_for_account(@me) do locale_for_account(@me) do
thread_by_conversation(@status.conversation)
mail to: @me.user.email, subject: I18n.t('notification_mailer.favourite.subject', name: @account.acct) mail to: @me.user.email, subject: I18n.t('notification_mailer.favourite.subject', name: @account.acct)
end end
end end
@ -37,6 +39,7 @@ class NotificationMailer < ApplicationMailer
@status = notification.target_status @status = notification.target_status
locale_for_account(@me) do locale_for_account(@me) do
thread_by_conversation(@status.conversation)
mail to: @me.user.email, subject: I18n.t('notification_mailer.reblog.subject', name: @account.acct) mail to: @me.user.email, subject: I18n.t('notification_mailer.reblog.subject', name: @account.acct)
end end
end end
@ -67,4 +70,13 @@ class NotificationMailer < ApplicationMailer
) )
end end
end end
private
def thread_by_conversation(conversation)
return if conversation.nil?
msg_id = "<conversation-#{conversation.id}.#{conversation.created_at.strftime('%Y-%m-%d')}@#{Rails.configuration.x.local_domain}>"
headers['In-Reply-To'] = msg_id
headers['References'] = msg_id
end
end end