diff options
author | Rémy Coutable <remy@rymai.me> | 2016-03-17 20:03:51 +0100 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2016-03-25 13:05:15 +0100 |
commit | 9f218fc184894d61c10f738c59bce97780f06e25 (patch) | |
tree | edc94e1c3ac7bae80edb14f86810a12e98e13f5e /lib/gitlab/incoming_email.rb | |
parent | 31e76baf610e1307090a6bac3a7b3d525bce057a (diff) | |
download | gitlab-ce-2364-fallback-to-in-reply-to-header.tar.gz |
Improve and finish the fallback to the In-Reply-To and References header for the reply-by-email feature2364-fallback-to-in-reply-to-header
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
Diffstat (limited to 'lib/gitlab/incoming_email.rb')
-rw-r--r-- | lib/gitlab/incoming_email.rb | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/lib/gitlab/incoming_email.rb b/lib/gitlab/incoming_email.rb index 9068d79c95e..8ce9d32abe0 100644 --- a/lib/gitlab/incoming_email.rb +++ b/lib/gitlab/incoming_email.rb @@ -1,13 +1,10 @@ module Gitlab module IncomingEmail class << self - def enabled? - config.enabled && address_formatted_correctly? - end + FALLBACK_REPLY_MESSAGE_ID_REGEX = /\Areply\-(.+)@#{Gitlab.config.gitlab.host}\Z/.freeze - def address_formatted_correctly? - config.address && - config.address.include?("%{key}") + def enabled? + config.enabled && config.address end def reply_address(key) @@ -24,6 +21,13 @@ module Gitlab match[1] end + def key_from_fallback_reply_message_id(message_id) + match = message_id.match(FALLBACK_REPLY_MESSAGE_ID_REGEX) + return unless match + + match[1] + end + def config Gitlab.config.incoming_email end |