summaryrefslogtreecommitdiff
path: root/app/services/issues
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 /app/services/issues
parent58df72fac1252e09ca6043ac8d78548882c062be (diff)
downloadgitlab-ce-93812f2594ab871d613e29ff33ef4eefe298aeaa.tar.gz
Add initial notifications and hooks for issue move
Diffstat (limited to 'app/services/issues')
-rw-r--r--app/services/issues/move_service.rb37
1 files changed, 30 insertions, 7 deletions
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