2014-04-02 06:54:41 -04:00
|
|
|
module Issues
|
2014-04-02 12:55:23 -04:00
|
|
|
class UpdateService < Issues::BaseService
|
2014-04-02 06:54:41 -04:00
|
|
|
def execute(issue)
|
2015-11-17 06:42:43 -05:00
|
|
|
update(issue)
|
2014-04-02 06:54:41 -04:00
|
|
|
end
|
2015-11-12 18:13:45 -05:00
|
|
|
|
2016-08-12 17:54:32 -04:00
|
|
|
def handle_changes(issue, old_labels: [], old_mentioned_users: [])
|
2016-03-01 11:33:13 -05:00
|
|
|
if has_changes?(issue, old_labels: old_labels)
|
2016-02-20 08:59:59 -05:00
|
|
|
todo_service.mark_pending_todos_as_done(issue, current_user)
|
2016-02-18 16:12:52 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
if issue.previous_changes.include?('title') ||
|
2016-05-18 13:56:13 -04:00
|
|
|
issue.previous_changes.include?('description')
|
2016-02-20 08:59:59 -05:00
|
|
|
todo_service.update_issue(issue, current_user)
|
2016-02-15 21:26:33 -05:00
|
|
|
end
|
|
|
|
|
2015-11-12 18:13:45 -05:00
|
|
|
if issue.previous_changes.include?('milestone_id')
|
|
|
|
create_milestone_note(issue)
|
|
|
|
end
|
|
|
|
|
|
|
|
if issue.previous_changes.include?('assignee_id')
|
|
|
|
create_assignee_note(issue)
|
|
|
|
notification_service.reassigned_issue(issue, current_user)
|
2016-02-20 08:59:59 -05:00
|
|
|
todo_service.reassigned_issue(issue, current_user)
|
2015-11-12 18:13:45 -05:00
|
|
|
end
|
2016-02-12 09:58:39 -05:00
|
|
|
|
2016-04-20 18:41:11 -04:00
|
|
|
if issue.previous_changes.include?('confidential')
|
|
|
|
create_confidentiality_note(issue)
|
|
|
|
end
|
|
|
|
|
2016-03-01 11:33:13 -05:00
|
|
|
added_labels = issue.labels - old_labels
|
|
|
|
if added_labels.present?
|
|
|
|
notification_service.relabeled_issue(issue, added_labels, current_user)
|
2016-02-12 09:58:39 -05:00
|
|
|
end
|
2016-08-12 17:54:32 -04:00
|
|
|
|
|
|
|
added_mentions = issue.mentioned_users - old_mentioned_users
|
|
|
|
if added_mentions.present?
|
|
|
|
notification_service.new_mentions_in_issue(issue, added_mentions, current_user)
|
|
|
|
end
|
2015-11-12 18:13:45 -05:00
|
|
|
end
|
2015-11-17 06:42:43 -05:00
|
|
|
|
|
|
|
def reopen_service
|
|
|
|
Issues::ReopenService
|
|
|
|
end
|
|
|
|
|
|
|
|
def close_service
|
|
|
|
Issues::CloseService
|
|
|
|
end
|
2016-05-18 13:56:13 -04:00
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def create_confidentiality_note(issue)
|
|
|
|
SystemNoteService.change_issue_confidentiality(issue, issue.project, current_user)
|
|
|
|
end
|
2014-04-02 06:54:41 -04:00
|
|
|
end
|
|
|
|
end
|