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)
|
2016-08-09 11:51:40 -04:00
|
|
|
return issue unless can?(current_user, :update_issue, issue)
|
|
|
|
|
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)
|
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
|
2014-04-02 08:38:24 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
issue
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
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
|