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
2b028525
Commit
2b028525
authored
Jan 25, 2015
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add issue/mr participants to reasign events
Also refactor NotificationService a bit
parent
61548815
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
39 deletions
+22
-39
CHANGELOG
CHANGELOG
+1
-1
app/services/notification_service.rb
app/services/notification_service.rb
+15
-37
spec/services/notification_service_spec.rb
spec/services/notification_service_spec.rb
+6
-1
No files found.
CHANGELOG
View file @
2b028525
...
@@ -3,7 +3,7 @@ Note: The upcoming release contains empty lines to reduce the number of merge co
...
@@ -3,7 +3,7 @@ Note: The upcoming release contains empty lines to reduce the number of merge co
v 7.8.0
v 7.8.0
- Replace highlight.js with rouge-fork rugments (Stefan Tatschner)
- Replace highlight.js with rouge-fork rugments (Stefan Tatschner)
- Make project search case insensitive (Hannes Rosenögger)
- Make project search case insensitive (Hannes Rosenögger)
- Include issue/mr participants in list of recipients for close/reopen emails
- Include issue/mr participants in list of recipients for
reassign/
close/reopen emails
- Expose description in groups API
- Expose description in groups API
-
-
-
-
...
...
app/services/notification_service.rb
View file @
2b028525
...
@@ -314,15 +314,7 @@ class NotificationService
...
@@ -314,15 +314,7 @@ class NotificationService
end
end
def
new_resource_email
(
target
,
project
,
method
)
def
new_resource_email
(
target
,
project
,
method
)
if
target
.
respond_to?
(
:participants
)
recipients
=
build_recipients
(
target
,
project
)
recipients
=
target
.
participants
else
recipients
=
[]
end
recipients
=
reject_muted_users
(
recipients
,
project
)
recipients
=
reject_mention_users
(
recipients
,
project
)
recipients
=
recipients
.
concat
(
project_watchers
(
project
)).
uniq
recipients
.
delete
(
target
.
author
)
recipients
.
delete
(
target
.
author
)
recipients
.
each
do
|
recipient
|
recipients
.
each
do
|
recipient
|
...
@@ -331,16 +323,7 @@ class NotificationService
...
@@ -331,16 +323,7 @@ class NotificationService
end
end
def
close_resource_email
(
target
,
project
,
current_user
,
method
)
def
close_resource_email
(
target
,
project
,
current_user
,
method
)
participants
=
recipients
=
build_recipients
(
target
,
project
)
if
target
.
respond_to?
(
:participants
)
target
.
participants
else
[
target
.
author
,
target
.
assignee
]
end
recipients
=
reject_muted_users
(
participants
,
project
)
recipients
=
reject_mention_users
(
recipients
,
project
)
recipients
=
recipients
.
concat
(
project_watchers
(
project
)).
uniq
recipients
.
delete
(
current_user
)
recipients
.
delete
(
current_user
)
recipients
.
each
do
|
recipient
|
recipients
.
each
do
|
recipient
|
...
@@ -350,17 +333,7 @@ class NotificationService
...
@@ -350,17 +333,7 @@ class NotificationService
def
reassign_resource_email
(
target
,
project
,
current_user
,
method
)
def
reassign_resource_email
(
target
,
project
,
current_user
,
method
)
assignee_id_was
=
previous_record
(
target
,
"assignee_id"
)
assignee_id_was
=
previous_record
(
target
,
"assignee_id"
)
recipients
=
build_recipients
(
target
,
project
)
recipients
=
User
.
where
(
id:
[
target
.
assignee_id
,
assignee_id_was
])
# Add watchers to email list
recipients
=
recipients
.
concat
(
project_watchers
(
project
))
# reject users with disabled notifications
recipients
=
reject_muted_users
(
recipients
,
project
)
recipients
=
reject_mention_users
(
recipients
,
project
)
# Reject me from recipients if I reassign an item
recipients
.
delete
(
current_user
)
recipients
.
delete
(
current_user
)
recipients
.
each
do
|
recipient
|
recipients
.
each
do
|
recipient
|
...
@@ -369,21 +342,26 @@ class NotificationService
...
@@ -369,21 +342,26 @@ class NotificationService
end
end
def
reopen_resource_email
(
target
,
project
,
current_user
,
method
,
status
)
def
reopen_resource_email
(
target
,
project
,
current_user
,
method
,
status
)
participants
=
recipients
=
build_recipients
(
target
,
project
)
recipients
.
delete
(
current_user
)
recipients
.
each
do
|
recipient
|
mailer
.
send
(
method
,
recipient
.
id
,
target
.
id
,
status
,
current_user
.
id
)
end
end
def
build_recipients
(
target
,
project
)
recipients
=
if
target
.
respond_to?
(
:participants
)
if
target
.
respond_to?
(
:participants
)
target
.
participants
target
.
participants
else
else
[
target
.
author
,
target
.
assignee
]
[
target
.
author
,
target
.
assignee
]
end
end
recipients
=
reject_muted_users
(
participa
nts
,
project
)
recipients
=
reject_muted_users
(
recipie
nts
,
project
)
recipients
=
reject_mention_users
(
recipients
,
project
)
recipients
=
reject_mention_users
(
recipients
,
project
)
recipients
=
recipients
.
concat
(
project_watchers
(
project
)).
uniq
recipients
=
recipients
.
concat
(
project_watchers
(
project
)).
uniq
recipients
.
delete
(
current_user
)
recipients
recipients
.
each
do
|
recipient
|
mailer
.
send
(
method
,
recipient
.
id
,
target
.
id
,
status
,
current_user
.
id
)
end
end
end
def
mailer
def
mailer
...
...
spec/services/notification_service_spec.rb
View file @
2b028525
...
@@ -187,7 +187,7 @@ describe NotificationService do
...
@@ -187,7 +187,7 @@ describe NotificationService do
end
end
describe
'Issues'
do
describe
'Issues'
do
let
(
:issue
)
{
create
:issue
,
assignee:
create
(
:user
)
}
let
(
:issue
)
{
create
:issue
,
assignee:
create
(
:user
)
,
description:
'cc @participant'
}
before
do
before
do
build_team
(
issue
.
project
)
build_team
(
issue
.
project
)
...
@@ -197,6 +197,7 @@ describe NotificationService do
...
@@ -197,6 +197,7 @@ describe NotificationService do
it
do
it
do
should_email
(
issue
.
assignee_id
)
should_email
(
issue
.
assignee_id
)
should_email
(
@u_watcher
.
id
)
should_email
(
@u_watcher
.
id
)
should_email
(
@u_participant_mentioned
.
id
)
should_not_email
(
@u_mentioned
.
id
)
should_not_email
(
@u_mentioned
.
id
)
should_not_email
(
@u_participating
.
id
)
should_not_email
(
@u_participating
.
id
)
should_not_email
(
@u_disabled
.
id
)
should_not_email
(
@u_disabled
.
id
)
...
@@ -222,6 +223,7 @@ describe NotificationService do
...
@@ -222,6 +223,7 @@ describe NotificationService do
it
'should email new assignee'
do
it
'should email new assignee'
do
should_email
(
issue
.
assignee_id
)
should_email
(
issue
.
assignee_id
)
should_email
(
@u_watcher
.
id
)
should_email
(
@u_watcher
.
id
)
should_email
(
@u_participant_mentioned
.
id
)
should_not_email
(
@u_participating
.
id
)
should_not_email
(
@u_participating
.
id
)
should_not_email
(
@u_disabled
.
id
)
should_not_email
(
@u_disabled
.
id
)
...
@@ -242,6 +244,7 @@ describe NotificationService do
...
@@ -242,6 +244,7 @@ describe NotificationService do
should_email
(
issue
.
assignee_id
)
should_email
(
issue
.
assignee_id
)
should_email
(
issue
.
author_id
)
should_email
(
issue
.
author_id
)
should_email
(
@u_watcher
.
id
)
should_email
(
@u_watcher
.
id
)
should_email
(
@u_participant_mentioned
.
id
)
should_not_email
(
@u_participating
.
id
)
should_not_email
(
@u_participating
.
id
)
should_not_email
(
@u_disabled
.
id
)
should_not_email
(
@u_disabled
.
id
)
...
@@ -262,6 +265,7 @@ describe NotificationService do
...
@@ -262,6 +265,7 @@ describe NotificationService do
should_email
(
issue
.
assignee_id
)
should_email
(
issue
.
assignee_id
)
should_email
(
issue
.
author_id
)
should_email
(
issue
.
author_id
)
should_email
(
@u_watcher
.
id
)
should_email
(
@u_watcher
.
id
)
should_email
(
@u_participant_mentioned
.
id
)
should_not_email
(
@u_participating
.
id
)
should_not_email
(
@u_participating
.
id
)
should_not_email
(
@u_disabled
.
id
)
should_not_email
(
@u_disabled
.
id
)
...
@@ -404,6 +408,7 @@ describe NotificationService do
...
@@ -404,6 +408,7 @@ describe NotificationService do
def
build_team
(
project
)
def
build_team
(
project
)
@u_watcher
=
create
(
:user
,
notification_level:
Notification
::
N_WATCH
)
@u_watcher
=
create
(
:user
,
notification_level:
Notification
::
N_WATCH
)
@u_participating
=
create
(
:user
,
notification_level:
Notification
::
N_PARTICIPATING
)
@u_participating
=
create
(
:user
,
notification_level:
Notification
::
N_PARTICIPATING
)
@u_participant_mentioned
=
create
(
:user
,
username:
'participant'
,
notification_level:
Notification
::
N_PARTICIPATING
)
@u_disabled
=
create
(
:user
,
notification_level:
Notification
::
N_DISABLED
)
@u_disabled
=
create
(
:user
,
notification_level:
Notification
::
N_DISABLED
)
@u_mentioned
=
create
(
:user
,
username:
'mention'
,
notification_level:
Notification
::
N_MENTION
)
@u_mentioned
=
create
(
:user
,
username:
'mention'
,
notification_level:
Notification
::
N_MENTION
)
@u_committer
=
create
(
:user
,
username:
'committer'
)
@u_committer
=
create
(
:user
,
username:
'committer'
)
...
...
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