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
5ab75649
Commit
5ab75649
authored
Mar 30, 2018
by
Sean McGivern
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Only send issue due emails to participants and custom subscribers
parent
6412c4c5
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
39 additions
and
15 deletions
+39
-15
app/models/notification_setting.rb
app/models/notification_setting.rb
+2
-1
app/services/notification_recipient_service.rb
app/services/notification_recipient_service.rb
+2
-1
app/services/notification_service.rb
app/services/notification_service.rb
+2
-1
app/views/notify/issue_due_email.html.haml
app/views/notify/issue_due_email.html.haml
+1
-1
db/migrate/20180330121048_add_issue_due_to_notification_settings.rb
.../20180330121048_add_issue_due_to_notification_settings.rb
+9
-0
db/schema.rb
db/schema.rb
+2
-1
doc/api/notification_settings.md
doc/api/notification_settings.md
+4
-0
doc/workflow/notifications.md
doc/workflow/notifications.md
+7
-7
spec/services/notification_service_spec.rb
spec/services/notification_service_spec.rb
+10
-3
No files found.
app/models/notification_setting.rb
View file @
5ab75649
...
@@ -47,7 +47,8 @@ class NotificationSetting < ActiveRecord::Base
...
@@ -47,7 +47,8 @@ class NotificationSetting < ActiveRecord::Base
].
freeze
].
freeze
EXCLUDED_WATCHER_EVENTS
=
[
EXCLUDED_WATCHER_EVENTS
=
[
:push_to_merge_request
:push_to_merge_request
,
:issue_due
].
push
(
*
EXCLUDED_PARTICIPATING_EVENTS
).
freeze
].
push
(
*
EXCLUDED_PARTICIPATING_EVENTS
).
freeze
def
self
.
find_or_create_for
(
source
)
def
self
.
find_or_create_for
(
source
)
...
...
app/services/notification_recipient_service.rb
View file @
5ab75649
...
@@ -204,10 +204,11 @@ module NotificationRecipientService
...
@@ -204,10 +204,11 @@ module NotificationRecipientService
attr_reader
:action
attr_reader
:action
attr_reader
:previous_assignee
attr_reader
:previous_assignee
attr_reader
:skip_current_user
attr_reader
:skip_current_user
def
initialize
(
target
,
current_user
,
action
:,
previous_assignee:
nil
,
skip_current_user:
true
)
def
initialize
(
target
,
current_user
,
action
:,
custom_action:
nil
,
previous_assignee:
nil
,
skip_current_user:
true
)
@target
=
target
@target
=
target
@current_user
=
current_user
@current_user
=
current_user
@action
=
action
@action
=
action
@custom_action
=
custom_action
@previous_assignee
=
previous_assignee
@previous_assignee
=
previous_assignee
@skip_current_user
=
skip_current_user
@skip_current_user
=
skip_current_user
end
end
...
...
app/services/notification_service.rb
View file @
5ab75649
...
@@ -377,7 +377,8 @@ class NotificationService
...
@@ -377,7 +377,8 @@ class NotificationService
recipients
=
NotificationRecipientService
.
build_recipients
(
recipients
=
NotificationRecipientService
.
build_recipients
(
issue
,
issue
,
issue
.
author
,
issue
.
author
,
action:
"due_date"
,
action:
'due'
,
custom_action: :issue_due
,
skip_current_user:
false
skip_current_user:
false
)
)
...
...
app/views/notify/issue_due_email.html.haml
View file @
5ab75649
-
if
Gitlab
::
CurrentSettings
.
email_author_in_body
-
if
Gitlab
::
CurrentSettings
.
email_author_in_body
%p
.details
%p
.details
Issue created by
#{
link_to
@issue
.
author_name
,
user_url
(
@issue
.
author
)
}
is due:
#{
link_to
@issue
.
author_name
,
user_url
(
@issue
.
author
)
}
's issue is due soon.
-
if
@issue
.
assignees
.
any?
-
if
@issue
.
assignees
.
any?
%p
%p
...
...
db/migrate/20180330121048_add_issue_due_to_notification_settings.rb
0 → 100644
View file @
5ab75649
class
AddIssueDueToNotificationSettings
<
ActiveRecord
::
Migration
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
def
change
add_column
:notification_settings
,
:issue_due
,
:boolean
end
end
db/schema.rb
View file @
5ab75649
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
#
#
# It's strongly recommended that you check this file into your version control system.
# It's strongly recommended that you check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
version:
201803
27101207
)
do
ActiveRecord
::
Schema
.
define
(
version:
201803
30121048
)
do
# These are extensions that must be enabled in order to support this database
# These are extensions that must be enabled in order to support this database
enable_extension
"plpgsql"
enable_extension
"plpgsql"
...
@@ -1311,6 +1311,7 @@ ActiveRecord::Schema.define(version: 20180327101207) do
...
@@ -1311,6 +1311,7 @@ ActiveRecord::Schema.define(version: 20180327101207) do
t
.
boolean
"failed_pipeline"
t
.
boolean
"failed_pipeline"
t
.
boolean
"success_pipeline"
t
.
boolean
"success_pipeline"
t
.
boolean
"push_to_merge_request"
t
.
boolean
"push_to_merge_request"
t
.
boolean
"issue_due"
end
end
add_index
"notification_settings"
,
[
"source_id"
,
"source_type"
],
name:
"index_notification_settings_on_source_id_and_source_type"
,
using: :btree
add_index
"notification_settings"
,
[
"source_id"
,
"source_type"
],
name:
"index_notification_settings_on_source_id_and_source_type"
,
using: :btree
...
...
doc/api/notification_settings.md
View file @
5ab75649
...
@@ -23,6 +23,7 @@ new_issue
...
@@ -23,6 +23,7 @@ new_issue
reopen_issue
reopen_issue
close_issue
close_issue
reassign_issue
reassign_issue
issue_due
new_merge_request
new_merge_request
push_to_merge_request
push_to_merge_request
reopen_merge_request
reopen_merge_request
...
@@ -75,6 +76,7 @@ curl --request PUT --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab
...
@@ -75,6 +76,7 @@ curl --request PUT --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab
|
`reopen_issue`
| boolean | no | Enable/disable this notification |
|
`reopen_issue`
| boolean | no | Enable/disable this notification |
|
`close_issue`
| boolean | no | Enable/disable this notification |
|
`close_issue`
| boolean | no | Enable/disable this notification |
|
`reassign_issue`
| boolean | no | Enable/disable this notification |
|
`reassign_issue`
| boolean | no | Enable/disable this notification |
|
`issue_due`
| boolean | no | Enable/disable this notification |
|
`new_merge_request`
| boolean | no | Enable/disable this notification |
|
`new_merge_request`
| boolean | no | Enable/disable this notification |
|
`push_to_merge_request`
| boolean | no | Enable/disable this notification |
|
`push_to_merge_request`
| boolean | no | Enable/disable this notification |
|
`reopen_merge_request`
| boolean | no | Enable/disable this notification |
|
`reopen_merge_request`
| boolean | no | Enable/disable this notification |
...
@@ -142,6 +144,7 @@ curl --request PUT --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab
...
@@ -142,6 +144,7 @@ curl --request PUT --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab
|
`reopen_issue`
| boolean | no | Enable/disable this notification |
|
`reopen_issue`
| boolean | no | Enable/disable this notification |
|
`close_issue`
| boolean | no | Enable/disable this notification |
|
`close_issue`
| boolean | no | Enable/disable this notification |
|
`reassign_issue`
| boolean | no | Enable/disable this notification |
|
`reassign_issue`
| boolean | no | Enable/disable this notification |
|
`issue_due`
| boolean | no | Enable/disable this notification |
|
`new_merge_request`
| boolean | no | Enable/disable this notification |
|
`new_merge_request`
| boolean | no | Enable/disable this notification |
|
`push_to_merge_request`
| boolean | no | Enable/disable this notification |
|
`push_to_merge_request`
| boolean | no | Enable/disable this notification |
|
`reopen_merge_request`
| boolean | no | Enable/disable this notification |
|
`reopen_merge_request`
| boolean | no | Enable/disable this notification |
...
@@ -166,6 +169,7 @@ Example responses:
...
@@ -166,6 +169,7 @@ Example responses:
"reopen_issue"
:
false
,
"reopen_issue"
:
false
,
"close_issue"
:
false
,
"close_issue"
:
false
,
"reassign_issue"
:
false
,
"reassign_issue"
:
false
,
"issue_due"
:
false
,
"new_merge_request"
:
false
,
"new_merge_request"
:
false
,
"push_to_merge_request"
:
false
,
"push_to_merge_request"
:
false
,
"reopen_merge_request"
:
false
,
"reopen_merge_request"
:
false
,
...
...
doc/workflow/notifications.md
View file @
5ab75649
...
@@ -86,6 +86,7 @@ In most of the below cases, the notification will be sent to:
...
@@ -86,6 +86,7 @@ In most of the below cases, the notification will be sent to:
| Close issue | |
| Close issue | |
| Reassign issue | The above, plus the old assignee |
| Reassign issue | The above, plus the old assignee |
| Reopen issue | |
| Reopen issue | |
| Due issue | Participants and Custom notification level with this event selected |
| New merge request | |
| New merge request | |
| Push to merge request | Participants and Custom notification level with this event selected |
| Push to merge request | Participants and Custom notification level with this event selected |
| Reassign merge request | The above, plus the old assignee |
| Reassign merge request | The above, plus the old assignee |
...
@@ -96,15 +97,14 @@ In most of the below cases, the notification will be sent to:
...
@@ -96,15 +97,14 @@ In most of the below cases, the notification will be sent to:
| Failed pipeline | The author of the pipeline |
| Failed pipeline | The author of the pipeline |
| Successful pipeline | The author of the pipeline, if they have the custom notification setting for successful pipelines set |
| Successful pipeline | The author of the pipeline, if they have the custom notification setting for successful pipelines set |
In addition, if the title or description of an Issue or Merge Request is
In addition, if the title or description of an Issue or Merge Request is
changed, notifications will be sent to any
**new**
mentions by
`@username`
as
changed, notifications will be sent to any
**new**
mentions by
`@username`
as
if they had been mentioned in the original text.
if they had been mentioned in the original text.
You won't receive notifications for Issues, Merge Requests or Milestones
You won't receive notifications for Issues, Merge Requests or Milestones
created
created by yourself. You will only receive automatic notifications when
by yourself (except when an issue is due). You will only receive automatic
somebody else comments or adds changes to the ones that you've created or
notifications when somebody else comments or adds changes to the ones that
mentions you.
you've created or
mentions you.
### Email Headers
### Email Headers
...
@@ -122,7 +122,7 @@ Notification emails include headers that provide extra content about the notific
...
@@ -122,7 +122,7 @@ Notification emails include headers that provide extra content about the notific
| X-GitLab-NotificationReason | The reason for being notified. "mentioned", "assigned", etc |
| X-GitLab-NotificationReason | The reason for being notified. "mentioned", "assigned", etc |
#### X-GitLab-NotificationReason
#### X-GitLab-NotificationReason
This header holds the reason for the notification to have been sent out,
This header holds the reason for the notification to have been sent out,
where reason can be
`mentioned`
,
`assigned`
,
`own_activity`
, etc.
where reason can be
`mentioned`
,
`assigned`
,
`own_activity`
, etc.
Only one reason is sent out according to its priority:
Only one reason is sent out according to its priority:
-
`own_activity`
-
`own_activity`
...
@@ -130,7 +130,7 @@ Only one reason is sent out according to its priority:
...
@@ -130,7 +130,7 @@ Only one reason is sent out according to its priority:
-
`mentioned`
-
`mentioned`
The reason in this header will also be shown in the footer of the notification email. For example an email with the
The reason in this header will also be shown in the footer of the notification email. For example an email with the
reason
`assigned`
will have this sentence in the footer:
reason
`assigned`
will have this sentence in the footer:
`"You are receiving this email because you have been assigned an item on {configured GitLab hostname}"`
`"You are receiving this email because you have been assigned an item on {configured GitLab hostname}"`
**Note: Only reasons listed above have been implemented so far**
**Note: Only reasons listed above have been implemented so far**
...
...
spec/services/notification_service_spec.rb
View file @
5ab75649
...
@@ -935,16 +935,23 @@ describe NotificationService, :mailer do
...
@@ -935,16 +935,23 @@ describe NotificationService, :mailer do
end
end
describe
'#issue_due'
do
describe
'#issue_due'
do
it
'sends email to issue notification recipients'
do
before
do
update_custom_notification
(
:issue_due
,
@u_guest_custom
,
resource:
project
)
update_custom_notification
(
:issue_due
,
@u_custom_global
)
end
it
'sends email to issue notification recipients, excluding watchers'
do
notification
.
issue_due
(
issue
)
notification
.
issue_due
(
issue
)
should_email
(
issue
.
assignees
.
first
)
should_email
(
issue
.
assignees
.
first
)
should_email
(
issue
.
author
)
should_email
(
issue
.
author
)
should_email
(
@u_
watcher
)
should_email
(
@u_
guest_custom
)
should_email
(
@u_
guest_watcher
)
should_email
(
@u_
custom_global
)
should_email
(
@u_participant_mentioned
)
should_email
(
@u_participant_mentioned
)
should_email
(
@subscriber
)
should_email
(
@subscriber
)
should_email
(
@watcher_and_subscriber
)
should_email
(
@watcher_and_subscriber
)
should_not_email
(
@u_watcher
)
should_not_email
(
@u_guest_watcher
)
should_not_email
(
@unsubscriber
)
should_not_email
(
@unsubscriber
)
should_not_email
(
@u_participating
)
should_not_email
(
@u_participating
)
should_not_email
(
@u_disabled
)
should_not_email
(
@u_disabled
)
...
...
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