2014-04-02 06:38:35 -04:00
|
|
|
module Issues
|
2014-04-02 12:55:23 -04:00
|
|
|
class CreateService < Issues::BaseService
|
2017-02-14 14:07:11 -05:00
|
|
|
include SpamCheckService
|
2017-02-27 12:12:52 -05:00
|
|
|
include ResolveDiscussions
|
2017-02-14 14:07:11 -05:00
|
|
|
|
2016-03-18 09:48:55 -04:00
|
|
|
def execute
|
2017-03-07 19:20:05 -05:00
|
|
|
@issue = BuildService.new(project, current_user, params).execute
|
|
|
|
|
2017-02-14 14:07:11 -05:00
|
|
|
filter_spam_check_params
|
2017-02-27 12:12:52 -05:00
|
|
|
filter_resolve_discussion_params
|
2014-04-02 06:38:35 -04:00
|
|
|
|
2016-08-16 18:49:53 -04:00
|
|
|
create(@issue)
|
2016-06-30 11:34:19 -04:00
|
|
|
end
|
2014-04-02 06:38:35 -04:00
|
|
|
|
2017-02-14 14:07:11 -05:00
|
|
|
def before_create(issue)
|
|
|
|
spam_check(issue, current_user)
|
2017-02-28 12:52:42 -05:00
|
|
|
issue.move_to_end
|
2016-08-16 20:59:55 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def after_create(issuable)
|
2016-06-30 11:34:19 -04:00
|
|
|
event_service.open_issue(issuable, current_user)
|
|
|
|
notification_service.new_issue(issuable, current_user)
|
|
|
|
todo_service.new_issue(issuable, current_user)
|
2016-08-16 18:49:53 -04:00
|
|
|
user_agent_detail_service.create
|
2016-12-22 07:31:12 -05:00
|
|
|
resolve_discussions_with_issue(issuable)
|
2016-10-26 17:21:50 -04:00
|
|
|
end
|
|
|
|
|
2017-03-07 19:30:43 -05:00
|
|
|
def resolve_discussions_with_issue(issue)
|
|
|
|
return if discussions_to_resolve.empty?
|
|
|
|
|
|
|
|
Discussions::ResolveService.new(project, current_user,
|
2017-03-10 03:19:12 -05:00
|
|
|
merge_request: merge_request_to_resolve_discussions_of,
|
2017-03-07 19:30:43 -05:00
|
|
|
follow_up_issue: issue).
|
|
|
|
execute(discussions_to_resolve)
|
|
|
|
end
|
|
|
|
|
2016-07-21 19:11:53 -04:00
|
|
|
private
|
|
|
|
|
2016-07-30 00:18:32 -04:00
|
|
|
def user_agent_detail_service
|
|
|
|
UserAgentDetailService.new(@issue, @request)
|
2016-07-21 19:11:53 -04:00
|
|
|
end
|
2014-04-02 06:38:35 -04:00
|
|
|
end
|
|
|
|
end
|