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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
e51bc96a
Commit
e51bc96a
authored
Jan 14, 2020
by
Felipe Artur
Committed by
Thong Kuah
Jan 14, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix reply emails with attachments for epics
Fix emails with attachments not creating notes on epics
parent
0e8d7147
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
50 additions
and
6 deletions
+50
-6
ee/changelogs/unreleased/issue_36060.yml
ee/changelogs/unreleased/issue_36060.yml
+5
-0
ee/lib/ee/gitlab/email/handler/reply_processing.rb
ee/lib/ee/gitlab/email/handler/reply_processing.rb
+10
-0
ee/spec/lib/gitlab/email/handler/create_note_handler_spec.rb
ee/spec/lib/gitlab/email/handler/create_note_handler_spec.rb
+12
-1
lib/gitlab/email/attachment_uploader.rb
lib/gitlab/email/attachment_uploader.rb
+2
-2
lib/gitlab/email/handler/reply_processing.rb
lib/gitlab/email/handler/reply_processing.rb
+8
-1
spec/lib/gitlab/email/attachment_uploader_spec.rb
spec/lib/gitlab/email/attachment_uploader_spec.rb
+1
-1
spec/lib/gitlab/email/handler/create_note_handler_spec.rb
spec/lib/gitlab/email/handler/create_note_handler_spec.rb
+12
-1
No files found.
ee/changelogs/unreleased/issue_36060.yml
0 → 100644
View file @
e51bc96a
---
title
:
Fix reply emails with attachments for epics
merge_request
:
22547
author
:
type
:
fixed
ee/lib/ee/gitlab/email/handler/reply_processing.rb
View file @
e51bc96a
...
...
@@ -24,6 +24,16 @@ module EE
def
process_message
(
**
kwargs
)
strip_quick_actions
(
super
(
kwargs
))
end
override
:upload_params
def
upload_params
return
super
unless
try
(
:noteable
)
&
.
is_a?
(
Epic
)
{
upload_parent:
noteable
.
group
,
uploader_class:
NamespaceFileUploader
}
end
end
end
end
...
...
ee/spec/lib/gitlab/email/handler/create_note_handler_spec.rb
View file @
e51bc96a
...
...
@@ -79,10 +79,21 @@ describe Gitlab::Email::Handler::CreateNoteHandler do
end
it
"adds all attachments"
do
expect_next_instance_of
(
Gitlab
::
Email
::
AttachmentUploader
)
do
|
uploader
|
expect
(
uploader
).
to
receive
(
:execute
).
with
(
upload_parent:
group
,
uploader_class:
NamespaceFileUploader
).
and_return
(
[
{
url:
"uploads/image.png"
,
alt:
"image"
,
markdown:
markdown
}
]
)
end
receiver
.
execute
note
=
noteable
.
notes
.
last
expect
(
note
.
note
).
to
include
(
markdown
)
end
...
...
lib/gitlab/email/attachment_uploader.rb
View file @
e51bc96a
...
...
@@ -9,7 +9,7 @@ module Gitlab
@message
=
message
end
def
execute
(
project
)
def
execute
(
upload_parent
:,
uploader_class
:
)
attachments
=
[]
message
.
attachments
.
each
do
|
attachment
|
...
...
@@ -23,7 +23,7 @@ module Gitlab
content_type:
attachment
.
content_type
}
uploader
=
UploadService
.
new
(
project
,
file
).
execute
uploader
=
UploadService
.
new
(
upload_parent
,
file
,
uploader_class
).
execute
attachments
<<
uploader
.
to_h
if
uploader
ensure
tmp
.
close!
...
...
lib/gitlab/email/handler/reply_processing.rb
View file @
e51bc96a
...
...
@@ -41,13 +41,20 @@ module Gitlab
end
def
add_attachments
(
reply
)
attachments
=
Email
::
AttachmentUploader
.
new
(
mail
).
execute
(
project
)
attachments
=
Email
::
AttachmentUploader
.
new
(
mail
).
execute
(
upload_params
)
reply
+
attachments
.
map
do
|
link
|
"
\n\n
#{
link
[
:markdown
]
}
"
end
.
join
end
def
upload_params
{
upload_parent:
project
,
uploader_class:
FileUploader
}
end
def
validate_permission!
(
permission
)
raise
UserNotFoundError
unless
author
raise
UserBlockedError
if
author
.
blocked?
...
...
spec/lib/gitlab/email/attachment_uploader_spec.rb
View file @
e51bc96a
...
...
@@ -9,7 +9,7 @@ describe Gitlab::Email::AttachmentUploader do
let
(
:message
)
{
Mail
::
Message
.
new
(
message_raw
)
}
it
"uploads all attachments and returns their links"
do
links
=
described_class
.
new
(
message
).
execute
(
project
)
links
=
described_class
.
new
(
message
).
execute
(
upload_parent:
project
,
uploader_class:
FileUploader
)
link
=
links
.
first
expect
(
link
).
not_to
be_nil
...
...
spec/lib/gitlab/email/handler/create_note_handler_spec.rb
View file @
e51bc96a
...
...
@@ -181,10 +181,21 @@ describe Gitlab::Email::Handler::CreateNoteHandler do
it_behaves_like
'a reply to existing comment'
it
"adds all attachments"
do
expect_next_instance_of
(
Gitlab
::
Email
::
AttachmentUploader
)
do
|
uploader
|
expect
(
uploader
).
to
receive
(
:execute
).
with
(
upload_parent:
project
,
uploader_class:
FileUploader
).
and_return
(
[
{
url:
"uploads/image.png"
,
alt:
"image"
,
markdown:
markdown
}
]
)
end
receiver
.
execute
note
=
noteable
.
notes
.
last
expect
(
note
.
note
).
to
include
(
markdown
)
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