debian-mirror-gitlab/app/services/issues/create_service.rb

44 lines
1.2 KiB
Ruby
Raw Normal View History

2014-09-02 18:07:02 +05:30
module Issues
class CreateService < Issues::BaseService
2017-08-17 22:00:37 +05:30
include SpamCheckService
include ResolveDiscussions
2014-09-02 18:07:02 +05:30
def execute
2017-08-17 22:00:37 +05:30
@issue = BuildService.new(project, current_user, params).execute
2014-09-02 18:07:02 +05:30
2017-08-17 22:00:37 +05:30
filter_spam_check_params
filter_resolve_discussion_params
2014-09-02 18:07:02 +05:30
2016-09-13 17:45:13 +05:30
create(@issue)
end
2017-08-17 22:00:37 +05:30
def before_create(issue)
spam_check(issue, current_user)
issue.move_to_end
2016-09-13 17:45:13 +05:30
end
def after_create(issuable)
event_service.open_issue(issuable, current_user)
notification_service.new_issue(issuable, current_user)
todo_service.new_issue(issuable, current_user)
user_agent_detail_service.create
2017-08-17 22:00:37 +05:30
resolve_discussions_with_issue(issuable)
2016-09-13 17:45:13 +05:30
end
2017-08-17 22:00:37 +05:30
def resolve_discussions_with_issue(issue)
return if discussions_to_resolve.empty?
2016-09-13 17:45:13 +05:30
2017-08-17 22:00:37 +05:30
Discussions::ResolveService.new(project, current_user,
merge_request: merge_request_to_resolve_discussions_of,
follow_up_issue: issue).
execute(discussions_to_resolve)
2016-09-13 17:45:13 +05:30
end
2017-08-17 22:00:37 +05:30
private
2016-09-13 17:45:13 +05:30
def user_agent_detail_service
UserAgentDetailService.new(@issue, @request)
2014-09-02 18:07:02 +05:30
end
end
end