Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
ee548b6e
Commit
ee548b6e
authored
May 20, 2016
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Only set @raw for receiver, and handle the rest in execute
parent
32eae15f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
11 deletions
+12
-11
lib/gitlab/email/receiver.rb
lib/gitlab/email/receiver.rb
+12
-11
No files found.
lib/gitlab/email/receiver.rb
View file @
ee548b6e
...
...
@@ -19,15 +19,16 @@ module Gitlab
class
InvalidIssueError
<
ProcessingError
;
end
class
Receiver
attr_reader
:mail
def
initialize
(
raw
)
raise
EmptyEmailError
if
raw
.
blank?
@mail
=
build_mail
(
raw
)
@raw
=
raw
end
def
execute
mail_key
=
extract_mail_key
raise
EmptyEmailError
if
@raw
.
blank?
mail
=
build_mail
mail_key
=
extract_mail_key
(
mail
)
raise
SentNotificationNotFoundError
unless
mail_key
if
handler
=
find_handler
(
mail
,
mail_key
)
...
...
@@ -40,25 +41,25 @@ module Gitlab
end
end
def
build_mail
(
raw
)
Mail
::
Message
.
new
(
raw
)
def
build_mail
Mail
::
Message
.
new
(
@
raw
)
rescue
Encoding
::
UndefinedConversionError
,
Encoding
::
InvalidByteSequenceError
=>
e
raise
EmailUnparsableError
,
e
end
def
extract_mail_key
key_from_to_header
||
key_from_additional_headers
def
extract_mail_key
(
mail
)
key_from_to_header
(
mail
)
||
key_from_additional_headers
(
mail
)
end
def
key_from_to_header
def
key_from_to_header
(
mail
)
mail
.
to
.
find
do
|
address
|
key
=
Gitlab
::
IncomingEmail
.
key_from_address
(
address
)
break
key
if
key
end
end
def
key_from_additional_headers
def
key_from_additional_headers
(
mail
)
Array
(
mail
.
references
).
find
do
|
mail_id
|
key
=
Gitlab
::
IncomingEmail
.
key_from_fallback_message_id
(
mail_id
)
break
key
if
key
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment