summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2016-03-14 13:24:56 +0100
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2016-03-17 07:39:16 +0100
commit93812f2594ab871d613e29ff33ef4eefe298aeaa (patch)
tree2d6d5920d4b73e69a8eedcb11822ca2d987d037d
parent58df72fac1252e09ca6043ac8d78548882c062be (diff)
downloadgitlab-ce-93812f2594ab871d613e29ff33ef4eefe298aeaa.tar.gz
Add initial notifications and hooks for issue move
-rw-r--r--app/assets/javascripts/project_select.js.coffee6
-rw-r--r--app/services/issues/move_service.rb37
-rw-r--r--app/services/notification_service.rb8
3 files changed, 38 insertions, 13 deletions
diff --git a/app/assets/javascripts/project_select.js.coffee b/app/assets/javascripts/project_select.js.coffee
index 4df61eb6ed6..9738a66ecb9 100644
--- a/app/assets/javascripts/project_select.js.coffee
+++ b/app/assets/javascripts/project_select.js.coffee
@@ -51,9 +51,6 @@ class @ProjectSelect
accessLevelCallbackDecorator: (callback) =>
return callback unless @accessLevel
- ##
- # Requires ECMAScript >= 5
- #
(projects) =>
data = projects.filter (p) =>
max = Math.max(p.permissions.group_access?.access_level ? 0,
@@ -66,9 +63,6 @@ class @ProjectSelect
withoutIdCallbackDecorator: (callback) =>
return callback unless @withoutId
- ##
- # Requires ECMAScript >= 5
- #
(projects) =>
data = projects.filter (p) =>
p.id != @withoutId
diff --git a/app/services/issues/move_service.rb b/app/services/issues/move_service.rb
index 25f970f0801..646ff876211 100644
--- a/app/services/issues/move_service.rb
+++ b/app/services/issues/move_service.rb
@@ -6,7 +6,7 @@ module Issues
@issue_old = issue
@issue_new = issue.dup
@project_old = @project
- @project_new = Project.find(new_project_id) if new_project_id
+ @project_new = Project.find(new_project_id)
end
def execute
@@ -25,9 +25,10 @@ module Issues
close_old_issue
end
- # Notifications
+ # Notifications and hooks
#
- notify_participants
+ # notify_participants
+ # trigger_hooks_and_events
@issue_new
end
@@ -44,10 +45,18 @@ module Issues
end
def create_new_issue
- @issue_new.iid = nil
@issue_new.project = @project_new
+
+ # Reset internal ID, will be regenerated before save
+ #
+ @issue_new.iid = nil
+
+ # Reset labels and milestones, as those are not valid in context
+ # of a new project
+ #
@issue_new.labels = []
@issue_new.milestone = nil
+
@issue_new.description = rewrite_references(@issue_old)
@issue_new.save!
end
@@ -66,9 +75,6 @@ module Issues
@issue_old.update(state: :closed)
end
- def notify_participants
- end
-
def add_moved_from_note
SystemNoteService.noteable_moved(:from, @issue_new, @project_new,
@issue_old, @current_user)
@@ -95,5 +101,22 @@ module Issues
raise 'Unexpected noteable while moving an issue'
end
end
+
+ def trigger_hooks_and_events
+ event_service.close_issue(@issue_old, @current_user)
+ event_service.open_issue(@issue_new, @current_user)
+
+ @issue_new.create_cross_references!(@current_user)
+
+ execute_hooks(@issue_old, 'close')
+ execute_hooks(@issue_new, 'open')
+ end
+
+ def notify_participants
+ todo_service.close_issue(@issue_old, @current_user)
+ todo_service.open_issue(@issue_new, @current_user)
+
+ 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..d90e630ff50 100644
--- a/app/services/notification_service.rb
+++ b/app/services/notification_service.rb
@@ -236,6 +236,14 @@ class NotificationService
end
end
+ def issue_moved(issue, old_project, new_project, current_user)
+ recipients = build_recipients(issue, old_project, current_user)
+
+ recipients.each do |recipient|
+ mailer.send('issue_moved', recipient.id, issue.id, current_user.id).deliver_later
+ end
+ end
+
protected
# Get project users with WATCH notification level