2018-11-18 11:00:15 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2014-09-02 18:07:02 +05:30
|
|
|
module Issues
|
|
|
|
class ReopenService < Issues::BaseService
|
|
|
|
def execute(issue)
|
2018-11-20 20:47:30 +05:30
|
|
|
return issue unless can?(current_user, :reopen_issue, issue)
|
2016-09-13 17:45:13 +05:30
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
before_reopen(issue)
|
|
|
|
|
2014-09-02 18:07:02 +05:30
|
|
|
if issue.reopen
|
|
|
|
event_service.reopen_issue(issue, current_user)
|
2017-09-10 17:25:29 +05:30
|
|
|
create_note(issue, 'reopened')
|
2018-10-15 14:42:47 +05:30
|
|
|
notification_service.async.reopen_issue(issue, current_user)
|
2014-09-02 18:07:02 +05:30
|
|
|
execute_hooks(issue, 'reopen')
|
2017-09-10 17:25:29 +05:30
|
|
|
invalidate_cache_counts(issue, users: issue.assignees)
|
2018-03-17 18:26:18 +05:30
|
|
|
issue.update_project_counter_caches
|
2020-04-08 14:13:33 +05:30
|
|
|
delete_milestone_closed_issue_counter_cache(issue.milestone)
|
2020-11-24 15:15:51 +05:30
|
|
|
track_incident_action(current_user, issue, :incident_reopened)
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
issue
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
def before_reopen(issue)
|
|
|
|
# Overriden in EE
|
|
|
|
end
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
def create_note(issue, state = issue.state)
|
|
|
|
SystemNoteService.change_status(issue, issue.project, current_user, state, nil)
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2021-01-03 14:25:43 +05:30
|
|
|
|
|
|
|
Issues::ReopenService.prepend_if_ee('EE::Issues::ReopenService')
|