2018-07-16 12:31:01 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
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
|
2017-08-01 08:38:45 -04:00
|
|
|
|
2017-08-08 03:41:27 -04:00
|
|
|
# current_user (defined in BaseService) is not available within run_after_commit block
|
2017-08-01 08:38:45 -04:00
|
|
|
user = current_user
|
|
|
|
issue.run_after_commit do
|
|
|
|
NewIssueWorker.perform_async(issue.id, user.id)
|
|
|
|
end
|
2016-08-16 20:59:55 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def after_create(issuable)
|
2016-06-30 11:34:19 -04:00
|
|
|
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)
|
2017-08-17 11:21:25 -04:00
|
|
|
|
|
|
|
super
|
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-06-21 09:48:12 -04:00
|
|
|
follow_up_issue: issue)
|
|
|
|
.execute(discussions_to_resolve)
|
2017-03-07 19:30:43 -05:00
|
|
|
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
|