From a1805cbcd55a28658049b42c12a87a50ab9ab977 Mon Sep 17 00:00:00 2001 From: Sean McGivern Date: Thu, 30 Mar 2017 12:29:52 +0100 Subject: Quiet pipeline emails 1. Never send a pipeline email to anyone other than the user who created the pipeline. 2. Only send pipeline success emails to people with the custom notification setting for enabled. Watchers and participants will never receive this. 3. When custom settings are unset (for new settings and legacy ones), act as if failed_pipeline is set. --- app/services/notification_service.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'app/services/notification_service.rb') diff --git a/app/services/notification_service.rb b/app/services/notification_service.rb index 2c6f849259e..6b186263bd1 100644 --- a/app/services/notification_service.rb +++ b/app/services/notification_service.rb @@ -278,11 +278,11 @@ class NotificationService return unless mailer.respond_to?(email_template) - recipients ||= NotificationRecipientService.new(pipeline.project).build_recipients( + recipients ||= NotificationRecipientService.new(pipeline.project).build_pipeline_recipients( pipeline, pipeline.user, action: pipeline.status, - skip_current_user: false).map(&:notification_email) + ).map(&:notification_email) if recipients.any? mailer.public_send(email_template, pipeline, recipients).deliver_later -- cgit v1.2.1 From 387c4b2c21a44360386a9b8ce6849e7f1b8a3de9 Mon Sep 17 00:00:00 2001 From: Valery Sizov Date: Thu, 4 May 2017 15:11:15 +0300 Subject: Backport of multiple_assignees_feature [ci skip] --- app/services/notification_service.rb | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) (limited to 'app/services/notification_service.rb') diff --git a/app/services/notification_service.rb b/app/services/notification_service.rb index 6b186263bd1..fe9f5ae2b33 100644 --- a/app/services/notification_service.rb +++ b/app/services/notification_service.rb @@ -66,8 +66,23 @@ class NotificationService # * issue new assignee if their notification level is not Disabled # * users with custom level checked with "reassign issue" # - def reassigned_issue(issue, current_user) - reassign_resource_email(issue, issue.project, current_user, :reassigned_issue_email) + def reassigned_issue(issue, current_user, previous_assignees = []) + recipients = NotificationRecipientService.new(issue.project).build_recipients( + issue, + current_user, + action: "reassign", + previous_assignee: previous_assignees + ) + + recipients.each do |recipient| + mailer.send( + :reassigned_issue_email, + recipient.id, + issue.id, + previous_assignees.map(&:id), + current_user.id + ).deliver_later + end end # When we add labels to an issue we should send an email to: @@ -367,10 +382,10 @@ class NotificationService end def previous_record(object, attribute) - if object && attribute - if object.previous_changes.include?(attribute) - object.previous_changes[attribute].first - end + return unless object && attribute + + if object.previous_changes.include?(attribute) + object.previous_changes[attribute].first end end end -- cgit v1.2.1 From 0f2a9681a318e5d27ef4e45195f2ac4b75f351dc Mon Sep 17 00:00:00 2001 From: Valery Sizov Date: Thu, 4 May 2017 18:52:01 +0300 Subject: [Multiple issue assignees] Resolving conflicts --- app/services/notification_service.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'app/services/notification_service.rb') diff --git a/app/services/notification_service.rb b/app/services/notification_service.rb index fe9f5ae2b33..c65c66d7150 100644 --- a/app/services/notification_service.rb +++ b/app/services/notification_service.rb @@ -74,12 +74,14 @@ class NotificationService previous_assignee: previous_assignees ) + previous_assignee_ids = previous_assignees.map(&:id) + recipients.each do |recipient| mailer.send( :reassigned_issue_email, recipient.id, issue.id, - previous_assignees.map(&:id), + previous_assignee_ids, current_user.id ).deliver_later end -- cgit v1.2.1 From 3db37e05622aa3daa2be41bb9edc486cd2e54bcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Coutable?= Date: Wed, 3 May 2017 13:27:17 +0200 Subject: Enable the Style/TrailingCommaInArguments cop MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use the EnforcedStyleForMultiline: no_comma option. Signed-off-by: Rémy Coutable --- app/services/notification_service.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/services/notification_service.rb') diff --git a/app/services/notification_service.rb b/app/services/notification_service.rb index c65c66d7150..646ccbdb2bf 100644 --- a/app/services/notification_service.rb +++ b/app/services/notification_service.rb @@ -298,7 +298,7 @@ class NotificationService recipients ||= NotificationRecipientService.new(pipeline.project).build_pipeline_recipients( pipeline, pipeline.user, - action: pipeline.status, + action: pipeline.status ).map(&:notification_email) if recipients.any? -- cgit v1.2.1