summaryrefslogtreecommitdiff
path: root/app
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
parentbebced8fc9039c5e8a3774af183a8dd9c244f297 (diff)
downloadgitlab-ce-5f39f9b30853291ec83df2383cd2e7863b72fb27.tar.gz
Send email to recipients
Diffstat (limited to 'app')
-rw-r--r--app/mailers/emails/issues.rb6
-rw-r--r--app/services/notification_recipient_service.rb10
-rw-r--r--app/services/notification_service.rb13
-rw-r--r--app/views/notify/issue_due_email.html.haml14
-rw-r--r--app/views/notify/issue_due_email.text.erb8
-rw-r--r--app/workers/issue_due_worker.rb3
6 files changed, 50 insertions, 4 deletions
diff --git a/app/mailers/emails/issues.rb b/app/mailers/emails/issues.rb
index b33131becd3..392cc0bee03 100644
--- a/app/mailers/emails/issues.rb
+++ b/app/mailers/emails/issues.rb
@@ -6,6 +6,12 @@ module Emails
mail_new_thread(@issue, issue_thread_options(@issue.author_id, recipient_id, reason))
end
+ def issue_due_email(recipient_id, issue_id, reason = nil)
+ setup_issue_mail(issue_id, recipient_id)
+
+ mail_new_thread(@issue, issue_thread_options(@issue.author_id, recipient_id, reason))
+ end
+
def new_mention_in_issue_email(recipient_id, issue_id, updated_by_user_id, reason = nil)
setup_issue_mail(issue_id, recipient_id)
mail_answer_thread(@issue, issue_thread_options(updated_by_user_id, recipient_id, reason))
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)
diff --git a/app/views/notify/issue_due_email.html.haml b/app/views/notify/issue_due_email.html.haml
new file mode 100644
index 00000000000..30ba53cf801
--- /dev/null
+++ b/app/views/notify/issue_due_email.html.haml
@@ -0,0 +1,14 @@
+- if Gitlab::CurrentSettings.email_author_in_body
+ %p.details
+ #{link_to @issue.author_name, user_url(@issue.author)} updated the issue's due date:
+
+- if @issue.assignees.any?
+ %p
+ Assignee: #{@issue.assignee_list}
+
+%p
+ This Issue has a new due date: #{ @issue.due_date }
+
+- if @issue.description
+ %div
+ = markdown(@issue.description, pipeline: :email, author: @issue.author)
diff --git a/app/views/notify/issue_due_email.text.erb b/app/views/notify/issue_due_email.text.erb
new file mode 100644
index 00000000000..1ac98bd9d93
--- /dev/null
+++ b/app/views/notify/issue_due_email.text.erb
@@ -0,0 +1,8 @@
+An Issue had its due date updated.
+
+Issue <%= @issue.iid %>: <%= url_for(project_issue_url(@issue.project, @issue)) %>
+Author: <%= @issue.author_name %>
+Assignee: <%= @issue.assignee_list %>
+New Due Date: <%= @issue.due_date %>
+
+<%= @issue.description %>
diff --git a/app/workers/issue_due_worker.rb b/app/workers/issue_due_worker.rb
index ba7f06ffc2f..ddd61d7b912 100644
--- a/app/workers/issue_due_worker.rb
+++ b/app/workers/issue_due_worker.rb
@@ -3,9 +3,8 @@ class IssueDueWorker
def perform(issue_id)
issue = Issue.find_by_id(issue_id)
- # How do we want to deal with noops?
if issue.due_date == Date.today
- # execute
+ NotificationService.new.issue_due_email(issue)
end
end
end