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
Kazuhiko Shiozaki
gitlab-ce
Commits
a769204f
Commit
a769204f
authored
Feb 10, 2012
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improved commit author notification
parent
adcfeae1
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
50 additions
and
16 deletions
+50
-16
app/mailers/notify.rb
app/mailers/notify.rb
+1
-2
app/models/mailer_observer.rb
app/models/mailer_observer.rb
+18
-13
app/models/note.rb
app/models/note.rb
+30
-0
app/views/notes/_form.html.haml
app/views/notes/_form.html.haml
+1
-1
No files found.
app/mailers/notify.rb
View file @
a769204f
...
...
@@ -27,8 +27,7 @@ class Notify < ActionMailer::Base
@user
=
user
@note
=
note
@project
=
note
.
project
@commit
=
@project
.
repo
.
commits
(
note
.
noteable_id
).
first
return
unless
(
note
.
notify
or
(
note
.
notify_author
and
@commit
.
author
.
email
==
@user
.
email
)
)
@commit
=
@note
.
target
mail
(
:to
=>
@user
.
email
,
:subject
=>
"gitlab | note for commit |
#{
@note
.
project
.
name
}
"
)
end
...
...
app/models/mailer_observer.rb
View file @
a769204f
...
...
@@ -27,20 +27,25 @@ class MailerObserver < ActiveRecord::Observer
end
def
new_note
(
note
)
return
unless
note
.
notify
or
note
.
notify_author
note
.
project
.
users
.
reject
{
|
u
|
u
.
id
==
current_user
.
id
}
.
each
do
|
u
|
case
note
.
noteable_type
when
"Commit"
then
Notify
.
note_commit_email
(
u
,
note
).
deliver
when
"Issue"
then
Notify
.
note_issue_email
(
u
,
note
).
deliver
when
"MergeRequest"
then
Notify
.
note_merge_request_email
(
u
,
note
).
deliver
when
"Snippet"
true
else
Notify
.
note_wall_email
(
u
,
note
).
deliver
# Notify whole team except author of note
if
note
.
notify
note
.
project
.
users
.
reject
{
|
u
|
u
.
id
==
current_user
.
id
}
.
each
do
|
u
|
case
note
.
noteable_type
when
"Commit"
then
Notify
.
note_commit_email
(
u
,
note
).
deliver
when
"Issue"
then
Notify
.
note_issue_email
(
u
,
note
).
deliver
when
"MergeRequest"
then
Notify
.
note_merge_request_email
(
u
,
note
).
deliver
when
"Snippet"
true
else
Notify
.
note_wall_email
(
u
,
note
).
deliver
end
end
# Notify only author of resource
elsif
note
.
notify_author
Notify
.
note_commit_email
(
note
.
commit_author
,
note
).
deliver
end
end
...
...
app/models/note.rb
View file @
a769204f
...
...
@@ -57,6 +57,36 @@ class Note < ActiveRecord::Base
rescue
nil
end
# Check if we can notify commit author
# with email about our comment
#
# If commit author email exist in project
# and commit author is not passed user we can
# send email to him
#
# params:
# user - current user
#
# return:
# Boolean
#
def
notify_only_author?
(
user
)
commit?
&&
commit_author
&&
commit_author
.
email
!=
user
.
email
end
def
commit?
noteable_type
==
"Commit"
end
def
commit_author
@commit_author
||=
project
.
users
.
find_by_email
(
target
.
author_email
)
||
project
.
users
.
find_by_name
(
target
.
author_name
)
rescue
nil
end
end
# == Schema Information
#
...
...
app/views/notes/_form.html.haml
View file @
a769204f
...
...
@@ -17,7 +17,7 @@
=
check_box_tag
:notify
,
1
,
@note
.
noteable_type
!=
"Commit"
%span
Project team
-
if
@note
.
noteable_type
==
"Commit"
-
if
@note
.
notify_only_author?
(
current_user
)
=
label_tag
:notify_author
do
=
check_box_tag
:notify_author
,
1
,
@note
.
noteable_type
==
"Commit"
%span
Commit author
...
...
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