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
Boxiang Sun
gitlab-ce
Commits
f6f6aaf5
Commit
f6f6aaf5
authored
Mar 15, 2017
by
Douwe Maan
Committed by
Luke "Jared" Bennett
Apr 05, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Better notification emails for notes and (diff) discussions
parent
76aa0bed
Changes
26
Hide whitespace changes
Inline
Side-by-side
Showing
26 changed files
with
106 additions
and
84 deletions
+106
-84
app/mailers/emails/notes.rb
app/mailers/emails/notes.rb
+5
-2
app/models/diff_discussion.rb
app/models/diff_discussion.rb
+3
-1
app/models/discussion.rb
app/models/discussion.rb
+4
-0
app/models/note.rb
app/models/note.rb
+1
-1
app/views/layouts/mailer.text.erb
app/views/layouts/mailer.text.erb
+4
-0
app/views/layouts/mailer.text.haml
app/views/layouts/mailer.text.haml
+0
-5
app/views/layouts/notify.text.erb
app/views/layouts/notify.text.erb
+12
-0
app/views/notify/_note_email.html.haml
app/views/notify/_note_email.html.haml
+36
-0
app/views/notify/_note_email.text.erb
app/views/notify/_note_email.text.erb
+25
-0
app/views/notify/_note_message.html.haml
app/views/notify/_note_message.html.haml
+0
-5
app/views/notify/_note_message.text.erb
app/views/notify/_note_message.text.erb
+0
-5
app/views/notify/_note_mr_or_commit_email.html.haml
app/views/notify/_note_mr_or_commit_email.html.haml
+0
-18
app/views/notify/_note_mr_or_commit_email.text.erb
app/views/notify/_note_mr_or_commit_email.text.erb
+0
-8
app/views/notify/_simple_diff.text.erb
app/views/notify/_simple_diff.text.erb
+0
-3
app/views/notify/note_commit_email.html.haml
app/views/notify/note_commit_email.html.haml
+1
-2
app/views/notify/note_commit_email.text.erb
app/views/notify/note_commit_email.text.erb
+1
-2
app/views/notify/note_issue_email.html.haml
app/views/notify/note_issue_email.html.haml
+1
-1
app/views/notify/note_issue_email.text.erb
app/views/notify/note_issue_email.text.erb
+1
-9
app/views/notify/note_merge_request_email.html.haml
app/views/notify/note_merge_request_email.html.haml
+1
-2
app/views/notify/note_merge_request_email.text.erb
app/views/notify/note_merge_request_email.text.erb
+1
-2
app/views/notify/note_personal_snippet_email.html.haml
app/views/notify/note_personal_snippet_email.html.haml
+1
-1
app/views/notify/note_personal_snippet_email.text.erb
app/views/notify/note_personal_snippet_email.text.erb
+1
-8
app/views/notify/note_snippet_email.html.haml
app/views/notify/note_snippet_email.html.haml
+1
-1
app/views/notify/note_snippet_email.text.erb
app/views/notify/note_snippet_email.text.erb
+1
-8
lib/gitlab/diff/line.rb
lib/gitlab/diff/line.rb
+4
-0
spec/mailers/notify_spec.rb
spec/mailers/notify_spec.rb
+2
-0
No files found.
app/mailers/emails/notes.rb
View file @
f6f6aaf5
...
...
@@ -4,7 +4,7 @@ module Emails
setup_note_mail
(
note_id
,
recipient_id
)
@commit
=
@note
.
noteable
@discussion
=
@note
.
to_discussion
if
@note
.
diff_note
?
@discussion
=
@note
.
discussion
if
@note
.
part_of_discussion
?
@target_url
=
namespace_project_commit_url
(
*
note_target_url_options
)
mail_answer_thread
(
@commit
,
...
...
@@ -17,6 +17,7 @@ module Emails
setup_note_mail
(
note_id
,
recipient_id
)
@issue
=
@note
.
noteable
@discussion
=
@note
.
discussion
if
@note
.
part_of_discussion?
@target_url
=
namespace_project_issue_url
(
*
note_target_url_options
)
mail_answer_thread
(
@issue
,
note_thread_options
(
recipient_id
))
end
...
...
@@ -25,7 +26,7 @@ module Emails
setup_note_mail
(
note_id
,
recipient_id
)
@merge_request
=
@note
.
noteable
@discussion
=
@note
.
to_discussion
if
@note
.
diff_note
?
@discussion
=
@note
.
discussion
if
@note
.
part_of_discussion
?
@target_url
=
namespace_project_merge_request_url
(
*
note_target_url_options
)
mail_answer_thread
(
@merge_request
,
note_thread_options
(
recipient_id
))
end
...
...
@@ -34,6 +35,7 @@ module Emails
setup_note_mail
(
note_id
,
recipient_id
)
@snippet
=
@note
.
noteable
@discussion
=
@note
.
discussion
if
@note
.
part_of_discussion?
@target_url
=
namespace_project_snippet_url
(
*
note_target_url_options
)
mail_answer_thread
(
@snippet
,
note_thread_options
(
recipient_id
))
end
...
...
@@ -42,6 +44,7 @@ module Emails
setup_note_mail
(
note_id
,
recipient_id
)
@snippet
=
@note
.
noteable
@discussion
=
@note
.
discussion
if
@note
.
part_of_discussion?
@target_url
=
snippet_url
(
@note
.
noteable
)
mail_answer_thread
(
@snippet
,
note_thread_options
(
recipient_id
))
end
...
...
app/models/diff_discussion.rb
View file @
f6f6aaf5
...
...
@@ -4,12 +4,14 @@ class DiffDiscussion < Discussion
delegate
:line_code
,
:original_line_code
,
:diff_file
,
:diff_line
,
:for_line?
,
:active?
,
to: :first_note
delegate
:blob
,
delegate
:file_path
,
:blob
,
:highlighted_diff_lines
,
:diff_lines
,
...
...
app/models/discussion.rb
View file @
f6f6aaf5
...
...
@@ -87,6 +87,10 @@ class Discussion
false
end
def
new_discussion?
notes
.
length
==
1
end
def
potentially_resolvable?
first_note
.
for_merge_request?
end
...
...
app/models/note.rb
View file @
f6f6aaf5
...
...
@@ -261,7 +261,7 @@ class Note < ActiveRecord::Base
# Returns the entire discussion this note is part of
def
discussion
if
part_of_discussion?
self
.
noteable
.
notes
.
find_discussion
(
self
.
discussion_id
)
self
.
noteable
.
notes
.
find_discussion
(
self
.
discussion_id
)
||
to_discussion
else
to_discussion
end
...
...
app/views/layouts/mailer.text.erb
0 → 100644
View file @
f6f6aaf5
<%=
yield
-%>
---
You're receiving this email because of your account on
<%=
Gitlab
.
config
.
gitlab
.
host
%>
.
app/views/layouts/mailer.text.haml
deleted
100644 → 0
View file @
76aa0bed
=
yield
You're receiving this email because of your account on
#{
Gitlab
.
config
.
gitlab
.
host
}
.
Manage all notifications:
#{
profile_notifications_url
}
Help:
#{
help_url
}
app/views/layouts/notify.text.erb
0 → 100644
View file @
f6f6aaf5
<%=
yield
-%>
---
<%
if
@target_url
-%>
<%
if
@reply_by_email
-%>
<%=
"Reply to this email directly or view it on GitLab:
#{
@target_url
}
"
-%>
<%
else
-%>
<%=
"View it on GitLab:
#{
@target_url
}
"
-%>
<%
end
-%>
<%
end
-%>
You're receiving this email because of your account on
<%=
Gitlab
.
config
.
gitlab
.
host
%>
.
app/views/notify/_note_email.html.haml
0 → 100644
View file @
f6f6aaf5
-
if
@discussion
%p
.details
=
succeed
':'
do
=
link_to
@note
.
author_name
,
user_url
(
@note
.
author
)
-
if
@discussion
.
diff_discussion?
-
if
@discussion
.
new_discussion?
started a new discussion
-
else
commented on a discussion
on
#{
link_to
@discussion
.
file_path
,
@target_url
}
-
else
-
if
@discussion
.
new_discussion?
started a new discussion
-
else
commented on a
#{
link_to
'discussion'
,
@target_url
}
-
elsif
current_application_settings
.
email_author_in_body
%p
.details
#{
link_to
@note
.
author_name
,
user_url
(
@note
.
author
)
}
commented:
-
if
@discussion
&
.
diff_discussion?
=
content_for
:head
do
=
stylesheet_link_tag
'mailers/highlighted_diff_email'
%table
=
render
partial:
"projects/diffs/line"
,
collection:
@discussion
.
truncated_diff_lines
,
as: :line
,
locals:
{
diff_file:
@discussion
.
diff_file
,
plain:
true
,
email:
true
}
%div
=
markdown
(
@note
.
note
,
pipeline: :email
,
author:
@note
.
author
)
app/views/notify/_note_email.text.erb
0 → 100644
View file @
f6f6aaf5
<%
if
@discussion
-%>
<%=
@note
.
author_name
-%>
<%
if
@discussion
.
new_discussion?
-%>
<%=
" started a new discussion"
-%>
<%
else
-%>
<%=
" commented on a discussion"
-%>
<%
end
-%>
<%
if
@discussion
.
diff_discussion?
-%>
<%=
" on
#{
@discussion
.
file_path
}
"
-%>
<%
end
-%>
<%=
":"
-%>
<%
elsif
current_application_settings
.
email_author_in_body
-%>
<%=
"
#{
@note
.
author_name
}
commented:"
-%>
<%
end
-%>
<%
if
@discussion
&
.
diff_discussion?
-%>
<%
@discussion
.
truncated_diff_lines
(
highlight:
false
).
each
do
|
line
|
-%>
<%=
">
#{
line
.
text
}
\n
"
-%>
<%
end
-%>
<%
end
-%>
<%=
@note
.
note
-%>
app/views/notify/_note_message.html.haml
deleted
100644 → 0
View file @
76aa0bed
-
if
current_application_settings
.
email_author_in_body
%div
#{
link_to
@note
.
author_name
,
user_url
(
@note
.
author
)
}
wrote:
%div
=
markdown
(
@note
.
note
,
pipeline: :email
,
author:
@note
.
author
)
app/views/notify/_note_message.text.erb
deleted
100644 → 0
View file @
76aa0bed
<%
if
current_application_settings
.
email_author_in_body
%>
<%=
@note
.
author_name
%>
wrote:
<%
end
-%>
<%=
@note
.
note
%>
app/views/notify/_note_mr_or_commit_email.html.haml
deleted
100644 → 0
View file @
76aa0bed
=
content_for
:head
do
=
stylesheet_link_tag
'mailers/highlighted_diff_email'
New comment
-
if
@discussion
&&
@discussion
.
diff_file
on
=
link_to
@note
.
diff_file
.
file_path
,
@target_url
,
class:
'details'
\:
%table
=
render
partial:
"projects/diffs/line"
,
collection:
@discussion
.
truncated_diff_lines
,
as: :line
,
locals:
{
diff_file:
@note
.
diff_file
,
plain:
true
,
email:
true
}
=
render
'note_message'
app/views/notify/_note_mr_or_commit_email.text.erb
deleted
100644 → 0
View file @
76aa0bed
<%
if
@discussion
&&
@discussion
.
diff_file
-%>
on
<%=
@note
.
diff_file
.
file_path
-%>
<%
end
-%>
:
<%=
url
%>
<%=
render
'simple_diff'
if
@discussion
-%>
<%=
render
'note_message'
%>
app/views/notify/_simple_diff.text.erb
deleted
100644 → 0
View file @
76aa0bed
<%
@discussion
.
truncated_diff_lines
(
highlight:
false
).
each
do
|
line
|
%>
>
<%=
line
.
text
%>
<%
end
%>
app/views/notify/note_commit_email.html.haml
View file @
f6f6aaf5
%p
.details
=
render
'note_mr_or_commit_email'
=
render
'note_email'
app/views/notify/note_commit_email.text.erb
View file @
f6f6aaf5
New comment for Commit
<%=
@commit
.
short_id
-%>
<%=
render
partial:
'note_mr_or_commit_email'
,
locals:
{
url:
@target_url
}
%>
<%=
render
partial:
'note_email'
%>
app/views/notify/note_issue_email.html.haml
View file @
f6f6aaf5
=
render
'note_
message
'
=
render
'note_
email
'
app/views/notify/note_issue_email.text.erb
View file @
f6f6aaf5
New comment for Issue
<%=
@issue
.
iid
%>
<%=
url_for
(
namespace_project_issue_url
(
@issue
.
project
.
namespace
,
@issue
.
project
,
@issue
,
anchor:
"note_
#{
@note
.
id
}
"
))
%>
Author:
<%=
@note
.
author_name
%>
<%=
@note
.
note
%>
<%=
render
partial:
'note_email'
%>
app/views/notify/note_merge_request_email.html.haml
View file @
f6f6aaf5
%p
.details
=
render
'note_mr_or_commit_email'
=
render
'note_email'
app/views/notify/note_merge_request_email.text.erb
View file @
f6f6aaf5
New comment for Merge Request
<%=
@merge_request
.
to_reference
-%>
<%=
render
partial:
'note_mr_or_commit_email'
,
locals:
{
url:
@target_url
}
%>
<%=
render
partial:
'note_email'
%>
app/views/notify/note_personal_snippet_email.html.haml
View file @
f6f6aaf5
=
render
'note_
message
'
=
render
'note_
email
'
app/views/notify/note_personal_snippet_email.text.erb
View file @
f6f6aaf5
New comment for Snippet
<%=
@snippet
.
id
%>
<%=
url_for
(
snippet_url
(
@snippet
,
anchor:
"note_
#{
@note
.
id
}
"
))
%>
Author:
<%=
@note
.
author_name
%>
<%=
@note
.
note
%>
<%=
render
partial:
'note_email'
%>
app/views/notify/note_snippet_email.html.haml
View file @
f6f6aaf5
=
render
'note_
message
'
=
render
'note_
email
'
app/views/notify/note_snippet_email.text.erb
View file @
f6f6aaf5
New comment for Snippet
<%=
@snippet
.
id
%>
<%=
url_for
(
namespace_project_snippet_url
(
@snippet
.
project
.
namespace
,
@snippet
.
project
,
@snippet
,
anchor:
"note_
#{
@note
.
id
}
"
))
%>
Author:
<%=
@note
.
author_name
%>
<%=
@note
.
note
%>
<%=
render
partial:
'note_email'
%>
lib/gitlab/diff/line.rb
View file @
f6f6aaf5
...
...
@@ -33,6 +33,10 @@ module Gitlab
new_pos
unless
removed?
||
meta?
end
def
line
new_line
||
old_line
end
def
unchanged?
type
.
nil?
end
...
...
spec/mailers/notify_spec.rb
View file @
f6f6aaf5
...
...
@@ -536,6 +536,8 @@ describe Notify do
allow
(
Note
).
to
receive
(
:find
).
with
(
note
.
id
).
and_return
(
note
)
end
# TODO: Test discussions
shared_examples
'a note email'
do
it_behaves_like
'it should have Gmail Actions links'
...
...
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