diff options
Diffstat (limited to 'lib/gitlab')
-rw-r--r-- | lib/gitlab/email/receiver.rb | 10 | ||||
-rw-r--r-- | lib/gitlab/incoming_email.rb | 16 |
2 files changed, 15 insertions, 11 deletions
diff --git a/lib/gitlab/email/receiver.rb b/lib/gitlab/email/receiver.rb index d55bacde5b0..97ef9851d71 100644 --- a/lib/gitlab/email/receiver.rb +++ b/lib/gitlab/email/receiver.rb @@ -63,10 +63,10 @@ module Gitlab end def reply_key - key_from_to_address || key_from_in_reply_to_header + key_from_to_header || key_from_additional_headers end - def key_from_to_address + def key_from_to_header key = nil message.to.each do |address| key = Gitlab::IncomingEmail.key_from_address(address) @@ -76,11 +76,11 @@ module Gitlab key end - def key_from_in_reply_to_header + def key_from_additional_headers reply_key = nil - message[:in_reply_to].message_ids.each do |message_id| - reply_key = Gitlab::IncomingEmail.key_from_address(message_id) + Array(message.references).each do |message_id| + reply_key = Gitlab::IncomingEmail.key_from_fallback_reply_message_id(message_id) break if reply_key end 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 |