summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2016-03-15 11:35:40 +0100
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2016-03-17 07:39:16 +0100
commit15d32b6a11380c257180dbc8e2691bc12e2792bc (patch)
tree9be5edc43e8ca447a79c000841b574b034c4d946 /app
parenta23f0e8c9ebd3a7922786d2fc4f3450c1fdecad6 (diff)
downloadgitlab-ce-15d32b6a11380c257180dbc8e2691bc12e2792bc.tar.gz
Add new notifications for issue move action
[ci skip]
Diffstat (limited to 'app')
-rw-r--r--app/mailers/emails/issues.rb8
-rw-r--r--app/services/issues/move_service.rb9
-rw-r--r--app/services/notification_service.rb10
-rw-r--r--app/views/notify/issue_moved_email.html.haml6
-rw-r--r--app/views/notify/issue_moved_email.text.erb4
5 files changed, 35 insertions, 2 deletions
diff --git a/app/mailers/emails/issues.rb b/app/mailers/emails/issues.rb
index 5f9adb32e00..6f54c42146c 100644
--- a/app/mailers/emails/issues.rb
+++ b/app/mailers/emails/issues.rb
@@ -36,6 +36,14 @@ module Emails
mail_answer_thread(@issue, issue_thread_options(updated_by_user_id, recipient_id))
end
+ def issue_moved_email(recipient, issue, new_issue, updated_by_user)
+ setup_issue_mail(issue.id, recipient.id)
+
+ @new_issue = new_issue
+ @new_project = new_issue.project
+ mail_answer_thread(issue, issue_thread_options(updated_by_user.id, recipient.id))
+ end
+
private
def setup_issue_mail(issue_id, recipient_id)
diff --git a/app/services/issues/move_service.rb b/app/services/issues/move_service.rb
index e2089e22bcb..4abcd203407 100644
--- a/app/services/issues/move_service.rb
+++ b/app/services/issues/move_service.rb
@@ -10,13 +10,17 @@ module Issues
if new_project_id
@project_new = Project.find(new_project_id)
end
+
+ if @project_new == @project_old
+ raise StandardError, 'Cannot move issue to project it originates from!'
+ end
end
def execute
return unless move?
- # Using trasaction because of a high footprint on
- # rewriting notes (unfolding references)
+ # Using trasaction because of a high resources footprint
+ # on rewriting notes (unfolding references)
#
ActiveRecord::Base.transaction do
# New issue tasks
@@ -99,6 +103,7 @@ module Issues
end
def notify_participants
+ notification_service.issue_moved(@issue_old, @issue_new, @current_user)
end
end
end
diff --git a/app/services/notification_service.rb b/app/services/notification_service.rb
index 19a6779dea9..3bdf00a8291 100644
--- a/app/services/notification_service.rb
+++ b/app/services/notification_service.rb
@@ -236,6 +236,16 @@ class NotificationService
end
end
+ def issue_moved(issue, new_issue, current_user)
+ recipients = build_recipients(issue, issue.project, current_user)
+
+ recipients.map do |recipient|
+ email = mailer.issue_moved_email(recipient, issue, new_issue, current_user)
+ email.deliver_later
+ email
+ end
+ end
+
protected
# Get project users with WATCH notification level
diff --git a/app/views/notify/issue_moved_email.html.haml b/app/views/notify/issue_moved_email.html.haml
new file mode 100644
index 00000000000..40f7d61fe19
--- /dev/null
+++ b/app/views/notify/issue_moved_email.html.haml
@@ -0,0 +1,6 @@
+%p
+ Issue was moved to another project.
+%p
+ New issue:
+ = link_to namespace_project_issue_url(@new_project.namespace, @new_project, @new_issue) do
+ = @new_issue.title
diff --git a/app/views/notify/issue_moved_email.text.erb b/app/views/notify/issue_moved_email.text.erb
new file mode 100644
index 00000000000..b3bd43c2055
--- /dev/null
+++ b/app/views/notify/issue_moved_email.text.erb
@@ -0,0 +1,4 @@
+Issue was moved to another project.
+
+New issue location:
+<%= namespace_project_issue_url(@new_project.namespace, @new_project, @new_issue) %>