diff options
author | Sean McGivern <sean@mcgivern.me.uk> | 2017-05-04 08:26:42 +0000 |
---|---|---|
committer | Sean McGivern <sean@mcgivern.me.uk> | 2017-05-04 08:26:42 +0000 |
commit | eddeecf65de0c37b495e5e857f2dd3a5f0b3ca9d (patch) | |
tree | c6879816a31cbc497ae5dc4a87bc3efcad5809a1 /lib | |
parent | e65ba684bc1b00192a1876ffd65084b790af4901 (diff) | |
parent | eb490365b589b8ace384bac617975a9031d9011c (diff) | |
download | gitlab-ce-eddeecf65de0c37b495e5e857f2dd3a5f0b3ca9d.tar.gz |
Merge branch '2247-emails-forwarded-to-service-desk-email-don-t-come' into 'master'
Handle incoming emails from aliases correctly
See merge request !11079
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/email/receiver.rb | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/lib/gitlab/email/receiver.rb b/lib/gitlab/email/receiver.rb index c270c0ea9ff..0d6b08b5d29 100644 --- a/lib/gitlab/email/receiver.rb +++ b/lib/gitlab/email/receiver.rb @@ -57,9 +57,8 @@ module Gitlab end def key_from_additional_headers(mail) - references = ensure_references_array(mail.references) - - find_key_from_references(references) + find_key_from_references(mail) || + find_key_from_delivered_to_header(mail) end def ensure_references_array(references) @@ -75,12 +74,19 @@ module Gitlab end end - def find_key_from_references(references) - references.find do |mail_id| + def find_key_from_references(mail) + ensure_references_array(mail.references).find do |mail_id| key = Gitlab::IncomingEmail.key_from_fallback_message_id(mail_id) break key if key end end + + def find_key_from_delivered_to_header(mail) + Array(mail[:delivered_to]).find do |header| + key = Gitlab::IncomingEmail.key_from_address(header.value) + break key if key + end + end end end end |