Skip to content
Snippets Groups Projects
Commit 93812f25 authored by Grzegorz Bizon's avatar Grzegorz Bizon
Browse files

Add initial notifications and hooks for issue move

parent 58df72fa
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -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,
Loading
Loading
@@ -66,9 +63,6 @@ class @ProjectSelect
withoutIdCallbackDecorator: (callback) =>
return callback unless @withoutId
 
##
# Requires ECMAScript >= 5
#
(projects) =>
data = projects.filter (p) =>
p.id != @withoutId
Loading
Loading
Loading
Loading
@@ -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
Loading
Loading
@@ -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
Loading
Loading
@@ -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
Loading
Loading
@@ -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)
Loading
Loading
@@ -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
Loading
Loading
@@ -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
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment