FEATURE: properly set 'In-Reply-To' header when sending an email that is a reply to an incoming email

This commit is contained in:
Régis Hanol 2016-04-06 21:04:30 +02:00
parent e09634dbae
commit 2c508f205a
1 changed files with 7 additions and 1 deletions

View File

@ -78,10 +78,16 @@ module Email
if topic_id.present?
email_log.topic_id = topic_id
incoming_email = IncomingEmail.find_by(post_id: post_id, topic_id: topic_id)
incoming_message_id = nil
incoming_message_id = "<#{incoming_email.message_id}>" if incoming_email.try(:message_id).present?
topic_identifier = "<topic/#{topic_id}@#{host}>"
post_identifier = "<topic/#{topic_id}/#{post_id}@#{host}>"
@message.header['Message-ID'] = post_identifier
@message.header['In-Reply-To'] = topic_identifier
@message.header['In-Reply-To'] = incoming_message_id || topic_identifier
@message.header['References'] = topic_identifier
topic = Topic.where(id: topic_id).first