summaryrefslogtreecommitdiff
path: root/app/services
diff options
context:
space:
mode:
authorStuart Nelson <stuartnelson3@gmail.com>2018-02-06 19:09:59 +0100
committerSean McGivern <sean@gitlab.com>2018-03-26 08:10:19 +0100
commit5f39f9b30853291ec83df2383cd2e7863b72fb27 (patch)
treeba59e062a442f0e796a25d176a6774efd1983cde /app/services
parentbebced8fc9039c5e8a3774af183a8dd9c244f297 (diff)
downloadgitlab-ce-5f39f9b30853291ec83df2383cd2e7863b72fb27.tar.gz
Send email to recipients
Diffstat (limited to 'app/services')
-rw-r--r--app/services/notification_recipient_service.rb10
-rw-r--r--app/services/notification_service.rb13
2 files changed, 21 insertions, 2 deletions
diff --git a/app/services/notification_recipient_service.rb b/app/services/notification_recipient_service.rb
index e4be953e810..c7c64356e30 100644
--- a/app/services/notification_recipient_service.rb
+++ b/app/services/notification_recipient_service.rb
@@ -230,14 +230,20 @@ module NotificationRecipientService
add_subscribed_users
- if [:new_issue, :new_merge_request].include?(custom_action)
+ if [:new_issue, :new_merge_request, :due_date_issue].include?(custom_action)
# These will all be participants as well, but adding with the :mention
# type ensures that users with the mention notification level will
# receive them, too.
add_mentions(current_user, target: target)
# Add the assigned users, if any
- assignees = custom_action == :new_issue ? target.assignees : target.assignee
+ assignees = case custom_action
+ when :new_issue, :due_date_issue
+ target.assignees
+ else
+ target.assignee
+ end
+
# We use the `:participating` notification level in order to match existing legacy behavior as captured
# in existing specs (notification_service_spec.rb ~ line 507)
add_recipients(assignees, :participating, NotificationReason::ASSIGNED) if assignees
diff --git a/app/services/notification_service.rb b/app/services/notification_service.rb
index d7d2cde1004..aade82f5cf1 100644
--- a/app/services/notification_service.rb
+++ b/app/services/notification_service.rb
@@ -363,6 +363,19 @@ class NotificationService
end
end
+ def issue_due_email(issue)
+ recipients = NotificationRecipientService.build_recipients(
+ issue,
+ issue.author,
+ action: "due_date",
+ skip_current_user: false,
+ )
+
+ recipients.each do |recipient|
+ mailer.send(:issue_due_email, recipient.user.id, issue.id, recipient.reason).deliver_later
+ end
+ end
+
protected
def new_resource_email(target, method)