Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre de La Morinerie <pierre@capitainetrain.com>2014-02-24 18:31:58 +0400
committerMarin Jankovski <marin@gitlab.com>2014-04-10 12:08:59 +0400
commit2729bdf3a0520b086543af2bb850556b0523b584 (patch)
treec290190fc4676b6926d1ef982538a2b7db8e3d40
parentc6ed52309614b30ffd38ca62629d5e0f7874dfbe (diff)
Don't send an email for "mentioned in" notes
Currently, an email is sent every time a mentionable is referenced by an issue, a commit or a merge request: if I comment "This MR is related to #5", watchers get one email for the comment, and another one stating "Issue #5 was mentioned by issue #13". This is annoying — but the biggest issue is when pushing an existing branch. Every issue referenced by commit messages in this branch will get a new mention (which is fine), and dozens of emails will be sent for all these new mentions (which is not). This commit fixes the spam by avoiding to send an email when a new mention is created. In most cases the email notification for the mentioner is enough.
-rw-r--r--app/services/notification_service.rb1
-rw-r--r--spec/services/notification_service_spec.rb8
2 files changed, 9 insertions, 0 deletions
diff --git a/app/services/notification_service.rb b/app/services/notification_service.rb
index 1b1a85b8858..6fda9868aa5 100644
--- a/app/services/notification_service.rb
+++ b/app/services/notification_service.rb
@@ -111,6 +111,7 @@ class NotificationService
# ignore gitlab service messages
return true if note.note =~ /\A_Status changed to closed_/
+ return true if note.note =~ /\A_mentioned in / && note.system == true
opts = { noteable_type: note.noteable_type, project_id: note.project_id }
diff --git a/spec/services/notification_service_spec.rb b/spec/services/notification_service_spec.rb
index 59c17d6e4d7..fbd73a7086f 100644
--- a/spec/services/notification_service_spec.rb
+++ b/spec/services/notification_service_spec.rb
@@ -32,6 +32,7 @@ describe NotificationService do
describe 'Notes' do
context 'issue note' do
let(:issue) { create(:issue, assignee: create(:user)) }
+ let(:mentioned_issue) { create(:issue, assignee: issue.assignee) }
let(:note) { create(:note_on_issue, noteable: issue, project_id: issue.project_id, note: '@mention referenced') }
before do
@@ -50,6 +51,13 @@ describe NotificationService do
notification.new_note(note)
end
+ it 'filters out "mentioned in" notes' do
+ mentioned_note = Note.create_cross_reference_note(mentioned_issue, issue, issue.author, issue.project)
+
+ Notify.should_not_receive(:note_issue_email)
+ notification.new_note(mentioned_note)
+ end
+
def should_email(user_id)
Notify.should_receive(:note_issue_email).with(user_id, note.id)
end