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
Jérome Perrin
gitlab-ce
Commits
ee1eb294
Commit
ee1eb294
authored
Aug 19, 2015
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Turn reply-by-email attachments into uploads.
parent
01c5eced
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
3 deletions
+36
-3
app/services/projects/upload_service.rb
app/services/projects/upload_service.rb
+3
-3
lib/gitlab/email_receiver.rb
lib/gitlab/email_receiver.rb
+33
-0
No files found.
app/services/projects/upload_service.rb
View file @
ee1eb294
...
...
@@ -13,9 +13,9 @@ module Projects
filename
=
uploader
.
image?
?
uploader
.
file
.
basename
:
uploader
.
file
.
filename
{
'alt'
=>
filename
,
'url'
=>
uploader
.
secure_url
,
'is_image'
=>
uploader
.
image?
alt:
filename
,
url:
uploader
.
secure_url
,
is_image:
uploader
.
image?
}
end
...
...
lib/gitlab/email_receiver.rb
View file @
ee1eb294
...
...
@@ -40,6 +40,10 @@ module Gitlab
body
=
parse_body
(
message
)
upload_attachments
.
each
do
|
link
|
body
<<
"
\n\n
#{
link
}
"
end
note
=
Notes
::
CreateService
.
new
(
project
,
author
,
...
...
@@ -152,5 +156,34 @@ module Gitlab
lines
[
0
..
range_end
].
join
.
strip
end
def
upload_attachments
attachments
=
[]
message
.
attachments
.
each
do
|
attachment
|
tmp
=
Tempfile
.
new
(
"gitlab-email-attachment"
)
begin
File
.
open
(
tmp
.
path
,
"w+b"
)
{
|
f
|
f
.
write
attachment
.
body
.
decoded
}
file
=
{
tempfile:
tmp
,
filename:
attachment
.
filename
,
content_type:
attachment
.
content_type
}
link
=
::
Projects
::
UploadService
.
new
(
sent_notification
.
project
,
file
).
execute
if
link
text
=
"[
#{
link
[
:alt
]
}
](
#{
link
[
:url
]
}
)"
text
.
prepend
(
"!"
)
if
link
[
:is_image
]
attachments
<<
text
end
ensure
tmp
.
close!
end
end
attachments
end
end
end
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