2018-07-16 12:31:01 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2014-04-02 08:38:24 -04:00
|
|
|
module Issues
|
2014-04-02 12:55:23 -04:00
|
|
|
class ReopenService < Issues::BaseService
|
2014-04-02 08:38:24 -04:00
|
|
|
def execute(issue)
|
2018-08-19 15:43:41 -04:00
|
|
|
return issue unless can?(current_user, :reopen_issue, issue)
|
2016-08-09 11:51:40 -04:00
|
|
|
|
2014-04-02 08:38:24 -04:00
|
|
|
if issue.reopen
|
|
|
|
event_service.reopen_issue(issue, current_user)
|
2017-07-19 10:03:50 -04:00
|
|
|
create_note(issue, 'reopened')
|
2018-04-20 13:37:38 -04:00
|
|
|
notification_service.async.reopen_issue(issue, current_user)
|
2021-08-05 11:09:46 -04:00
|
|
|
perform_incident_management_actions(issue)
|
2014-05-23 09:16:03 -04:00
|
|
|
execute_hooks(issue, 'reopen')
|
2017-07-11 12:12:33 -04:00
|
|
|
invalidate_cache_counts(issue, users: issue.assignees)
|
2017-10-30 12:20:29 -04:00
|
|
|
issue.update_project_counter_caches
|
2020-03-04 19:07:49 -05:00
|
|
|
delete_milestone_closed_issue_counter_cache(issue.milestone)
|
2020-09-10 17:08:28 -04:00
|
|
|
track_incident_action(current_user, issue, :incident_reopened)
|
2014-04-02 08:38:24 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
issue
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2021-08-05 11:09:46 -04:00
|
|
|
def perform_incident_management_actions(issue)
|
|
|
|
end
|
|
|
|
|
2017-07-19 10:03:50 -04:00
|
|
|
def create_note(issue, state = issue.state)
|
|
|
|
SystemNoteService.change_status(issue, issue.project, current_user, state, nil)
|
2014-04-02 08:38:24 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2021-08-05 11:09:46 -04:00
|
|
|
|
|
|
|
Issues::ReopenService.prepend_mod_with('Issues::ReopenService')
|