summaryrefslogtreecommitdiff
path: root/lib/gitlab/email/receiver.rb
diff options
context:
space:
mode:
authorFilipa Lacerda <filipa@gitlab.com>2017-02-07 12:01:59 +0000
committerFilipa Lacerda <filipa@gitlab.com>2017-02-07 12:01:59 +0000
commit21e9660dceb98c03920227fa1fbb682cf4769201 (patch)
tree6408eb0559cd8240839cd4963317b81156a6ce90 /lib/gitlab/email/receiver.rb
parentfbe48e133803d8654bdddcaf5d96dbf5e39b39bf (diff)
parent9810dc2e2a607aec81075fbfe60def6257a6d58f (diff)
downloadgitlab-ce-21e9660dceb98c03920227fa1fbb682cf4769201.tar.gz
Merge branch 'fe-paginated-environments-api' into fe-paginated-environments-paginationfe-paginated-environments-pagination
* fe-paginated-environments-api: (304 commits) added missed commit in rebase update Grape routes to work with current version of Grape adds changelog fixes cursor issue on pipeline pagination Use random group name to prevent conflicts List all groups/projects for admins on explore pages Fix indentation More backport Fix filtered search user autocomplete for gitlab instances that are hosted on a subdirectory Fixed variables_controller_spec.rb test Backport of the frontend view, including tests Updated the #create action to render the show view in case of a form error Improved code styling on the variables_controller_spec Added tests for the variables controller #update action Added a variable_controller_spec test to test for flash messages on the #create action Modified redirection logic in the variables cont. Added redirections to the index actions for the variables and triggers controllers Added a flash message to the creation of triggers Fixed tests, renamed files and methods Changed the controller/route name to 'ci/cd' and renamed the corresponding files ...
Diffstat (limited to 'lib/gitlab/email/receiver.rb')
-rw-r--r--lib/gitlab/email/receiver.rb21
1 files changed, 20 insertions, 1 deletions
diff --git a/lib/gitlab/email/receiver.rb b/lib/gitlab/email/receiver.rb
index a40c44eb1bc..b64db5d01ae 100644
--- a/lib/gitlab/email/receiver.rb
+++ b/lib/gitlab/email/receiver.rb
@@ -35,6 +35,8 @@ module Gitlab
handler.execute
end
+ private
+
def build_mail
Mail::Message.new(@raw)
rescue Encoding::UndefinedConversionError,
@@ -54,7 +56,24 @@ module Gitlab
end
def key_from_additional_headers(mail)
- Array(mail.references).find do |mail_id|
+ references = ensure_references_array(mail.references)
+
+ find_key_from_references(references)
+ end
+
+ def ensure_references_array(references)
+ case references
+ when Array
+ references
+ when String
+ # Handle emails from clients which append with commas,
+ # example clients are Microsoft exchange and iOS app
+ Gitlab::IncomingEmail.scan_fallback_references(references)
+ end
+ end
+
+ def find_key_from_references(references)
+ references.find do |mail_id|
key = Gitlab::IncomingEmail.key_from_fallback_message_id(mail_id)
break key if key
end