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
51d9eca0
Commit
51d9eca0
authored
Oct 18, 2019
by
Balasankar "Balu" C
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Set proper header to notification emails due to subscription
Signed-off-by:
Balasankar "Balu" C
<
balasankar@gitlab.com
>
parent
35d98e80
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
3 deletions
+33
-3
app/models/notification_reason.rb
app/models/notification_reason.rb
+3
-1
app/services/notification_recipient_service.rb
app/services/notification_recipient_service.rb
+2
-2
changelogs/unreleased/34416-subscribed-notification-header.yml
...elogs/unreleased/34416-subscribed-notification-header.yml
+5
-0
spec/services/notification_service_spec.rb
spec/services/notification_service_spec.rb
+23
-0
No files found.
app/models/notification_reason.rb
View file @
51d9eca0
...
...
@@ -6,12 +6,14 @@ class NotificationReason
OWN_ACTIVITY
=
'own_activity'
ASSIGNED
=
'assigned'
MENTIONED
=
'mentioned'
SUBSCRIBED
=
'subscribed'
# Priority list for selecting which reason to return in the notification
REASON_PRIORITY
=
[
OWN_ACTIVITY
,
ASSIGNED
,
MENTIONED
MENTIONED
,
SUBSCRIBED
].
freeze
# returns the priority of a reason as an integer
...
...
app/services/notification_recipient_service.rb
View file @
51d9eca0
...
...
@@ -181,7 +181,7 @@ module NotificationRecipientService
def
add_subscribed_users
return
unless
target
.
respond_to?
:subscribers
add_recipients
(
target
.
subscribers
(
project
),
:subscription
,
nil
)
add_recipients
(
target
.
subscribers
(
project
),
:subscription
,
NotificationReason
::
SUBSCRIBED
)
end
# rubocop: disable CodeReuse/ActiveRecord
...
...
@@ -240,7 +240,7 @@ module NotificationRecipientService
return
unless
target
.
respond_to?
:labels
(
labels
||
target
.
labels
).
each
do
|
label
|
add_recipients
(
label
.
subscribers
(
project
),
:subscription
,
nil
)
add_recipients
(
label
.
subscribers
(
project
),
:subscription
,
NotificationReason
::
SUBSCRIBED
)
end
end
end
...
...
changelogs/unreleased/34416-subscribed-notification-header.yml
0 → 100644
View file @
51d9eca0
---
title
:
Set X-GitLab-NotificationReason header if notification reason is explicit subscription
merge_request
:
18812
author
:
type
:
added
spec/services/notification_service_spec.rb
View file @
51d9eca0
...
...
@@ -869,6 +869,18 @@ describe NotificationService, :mailer do
should_email
(
user_4
)
end
it
'adds "subscribed" reason to subscriber emails'
do
user_1
=
create
(
:user
)
label
=
create
(
:label
,
project:
project
,
issues:
[
issue
])
issue
.
reload
label
.
subscribe
(
user_1
)
notification
.
new_issue
(
issue
,
@u_disabled
)
email
=
find_email_for
(
user_1
)
expect
(
email
).
to
have_header
(
'X-GitLab-NotificationReason'
,
NotificationReason
::
SUBSCRIBED
)
end
it_behaves_like
'project emails are disabled'
do
let
(
:notification_target
)
{
issue
}
let
(
:notification_trigger
)
{
notification
.
new_issue
(
issue
,
@u_disabled
)
}
...
...
@@ -1272,6 +1284,17 @@ describe NotificationService, :mailer do
let
(
:notification_target
)
{
issue
}
let
(
:notification_trigger
)
{
notification
.
close_issue
(
issue
,
@u_disabled
)
}
end
it
'adds "subscribed" reason to subscriber emails'
do
user_1
=
create
(
:user
)
issue
.
subscribe
(
user_1
)
issue
.
reload
notification
.
close_issue
(
issue
,
@u_disabled
)
email
=
find_email_for
(
user_1
)
expect
(
email
).
to
have_header
(
'X-GitLab-NotificationReason'
,
NotificationReason
::
SUBSCRIBED
)
end
end
describe
'#reopen_issue'
do
...
...
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