From 9f218fc184894d61c10f738c59bce97780f06e25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Coutable?= Date: Thu, 17 Mar 2016 20:03:51 +0100 Subject: Improve and finish the fallback to the In-Reply-To and References header for the reply-by-email feature A few things to note: - The IncomingEmail feature is now enabled even without a correctly-formatted sub-address - Message-ID for new thread mail are kept the same so that subsequent notifications to this thread are grouped in the thread by the email service that receives the notification (i.e. In-Reply-To of the answer == Message-ID of the first thread message) - To maximize our chance to be able to retrieve the reply key, we look for it in the In-Reply-To header and the References header - The pattern for the fallback reply message id is "reply-[key]@[gitlab_host]" - Improve docs thanks to Axil --- app/mailers/notify.rb | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'app/mailers/notify.rb') diff --git a/app/mailers/notify.rb b/app/mailers/notify.rb index e7331d88517..826e5f96fa1 100644 --- a/app/mailers/notify.rb +++ b/app/mailers/notify.rb @@ -110,6 +110,10 @@ class Notify < BaseMailer headers['Reply-To'] = address + fallback_reply_message_id = "".freeze + headers['References'] ||= '' + headers['References'] << ' ' << fallback_reply_message_id + @reply_by_email = true end @@ -121,17 +125,11 @@ class Notify < BaseMailer # # See: mail_answer_thread def mail_new_thread(model, headers = {}) - headers['Message-ID'] = message_reply_id - headers['In-Reply-To'] = message_id(model) - headers['References'] = message_id(model) + headers['Message-ID'] = message_id(model) mail_thread(model, headers) end - def message_reply_id - Gitlab.config.incoming_email["address"].gsub("%{key}", reply_key) - end - # Send an email that responds to an existing conversation thread, # with headers suitable for grouping by thread in email clients. # -- cgit v1.2.1