Commit 10af11f4 authored by Nick Thomas's avatar Nick Thomas

Allow people to subscribe to mentions in updated MRs and Issues

This slightly changes the semantics of the 'New Issue' and 'New MR' events to
include new mentions in edited Mentionables.

An alternative would be to introduce 'Issue updated' and 'MR updated' events,
but that would lead to questions about why those events were only available
to new mentions, and not existing mentions as well, so hold off for now.
parent 6642ae45
......@@ -500,7 +500,8 @@ class NotificationService
end
def new_mentions_in_resource_email(target, project, new_mentioned_users, current_user, method)
recipients = build_recipients(target, project, current_user) & new_mentioned_users
recipients = build_recipients(target, project, current_user, action: "new")
recipients = recipients & new_mentioned_users
recipients.each do |recipient|
mailer.send(method, recipient.id, target.id, current_user.id).deliver_later
......
......@@ -67,7 +67,7 @@ In all of the below cases, the notification will be sent to:
- Participants:
- the author and assignee of the issue/merge request
- authors of comments on the issue/merge request
- anyone mentioned by `@username` in the issue/merge request description
- anyone mentioned by `@username` in the issue/merge request title or description
- anyone mentioned by `@username` in any of the comments on the issue/merge request
...with notification level "Participating" or higher
......@@ -89,6 +89,11 @@ In all of the below cases, the notification will be sent to:
| Merge merge request | |
| New comment | The above, plus anyone mentioned by `@username` in the comment, with notification level "Mention" or higher |
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
if they had been mentioned in the original text.
You won't receive notifications for Issues, Merge Requests or Milestones
created by yourself. You will only receive automatic notifications when
somebody else comments or adds changes to the ones that you've created or
......
......@@ -411,12 +411,13 @@ describe NotificationService, services: true do
end
it "should email new mentions with a watch level higher than participant" do
send_notifications(@u_watcher, @u_participant_mentioned)
send_notifications(@u_watcher, @u_participant_mentioned, @u_custom_global)
should_email(@u_watcher)
should_email(@u_participant_mentioned)
should_email(@u_custom_global)
expect(ActionMailer::Base.deliveries.count).to eq 2
expect(ActionMailer::Base.deliveries.count).to eq 3
end
it "should not email new mentions with a watch level equal to or less than participant" do
......@@ -726,6 +727,8 @@ describe NotificationService, services: true do
before do
build_team(merge_request.target_project)
add_users_with_subscription(merge_request.target_project, merge_request)
update_custom_notification(:new_merge_request, @u_guest_custom, project)
update_custom_notification(:new_merge_request, @u_custom_global)
ActionMailer::Base.deliveries.clear
end
......@@ -801,12 +804,13 @@ describe NotificationService, services: true do
end
it "should email new mentions with a watch level higher than participant" do
send_notifications(@u_watcher, @u_participant_mentioned)
send_notifications(@u_watcher, @u_participant_mentioned, @u_custom_global)
should_email(@u_watcher)
should_email(@u_participant_mentioned)
should_email(@u_custom_global)
expect(ActionMailer::Base.deliveries.count).to eq 2
expect(ActionMailer::Base.deliveries.count).to eq 3
end
it "should not email new mentions with a watch level equal to or less than participant" do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment