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