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
|
2021-10-05 20:11:56 -04:00
|
|
|
def execute(issue, skip_authorization: false)
|
|
|
|
return issue unless can_reopen?(issue, skip_authorization: skip_authorization)
|
2016-08-09 11:51:40 -04:00
|
|
|
|
2021-10-05 20:11:56 -04:00
|
|
|
if perform_reopen(issue)
|
2014-04-02 08:38:24 -04:00
|
|
|
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-10-05 20:11:56 -04:00
|
|
|
# Overriden on EE
|
|
|
|
def perform_reopen(issue)
|
|
|
|
issue.reopen
|
|
|
|
end
|
|
|
|
|
|
|
|
def can_reopen?(issue, skip_authorization: false)
|
|
|
|
skip_authorization || can?(current_user, :reopen_issue, issue)
|
|
|
|
end
|
|
|
|
|
2021-08-05 11:09:46 -04:00
|
|
|
def perform_incident_management_actions(issue)
|
2022-07-01 11:08:30 -04:00
|
|
|
return unless issue.incident?
|
|
|
|
|
|
|
|
create_timeline_event(issue)
|
2021-08-05 11:09:46 -04:00
|
|
|
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
|
2022-07-01 11:08:30 -04:00
|
|
|
|
|
|
|
def create_timeline_event(issue)
|
|
|
|
IncidentManagement::TimelineEvents::CreateService.reopen_incident(issue, current_user)
|
|
|
|
end
|
2014-04-02 08:38:24 -04:00
|
|
|
end
|
|
|
|
end
|
2021-08-05 11:09:46 -04:00
|
|
|
|
|
|
|
Issues::ReopenService.prepend_mod_with('Issues::ReopenService')
|