2014-04-02 06:38:35 -04:00
|
|
|
module Issues
|
2014-04-02 12:55:23 -04:00
|
|
|
class CreateService < Issues::BaseService
|
2016-03-18 09:48:55 -04:00
|
|
|
def execute
|
2015-06-25 10:17:48 -04:00
|
|
|
filter_params
|
2016-07-21 19:11:53 -04:00
|
|
|
label_params = params.delete(:label_ids)
|
|
|
|
request = params.delete(:request)
|
|
|
|
api = params.delete(:api)
|
|
|
|
issue = project.issues.new(params)
|
2016-03-18 09:48:55 -04:00
|
|
|
issue.author = params[:author] || current_user
|
2014-04-02 06:38:35 -04:00
|
|
|
|
2016-07-28 20:02:56 -04:00
|
|
|
issue.spam = spam_check_service.execute(request, api, issue)
|
2016-07-18 19:17:43 -04:00
|
|
|
|
2014-04-02 06:38:35 -04:00
|
|
|
if issue.save
|
2014-07-30 15:48:21 -04:00
|
|
|
issue.update_attributes(label_ids: label_params)
|
2014-04-02 06:38:35 -04:00
|
|
|
notification_service.new_issue(issue, current_user)
|
2016-02-20 08:59:59 -05:00
|
|
|
todo_service.new_issue(issue, current_user)
|
2014-04-02 06:38:35 -04:00
|
|
|
event_service.open_issue(issue, current_user)
|
2016-07-27 20:03:06 -04:00
|
|
|
user_agent_detail_service(issue, request).create
|
2015-10-12 05:54:46 -04:00
|
|
|
issue.create_cross_references!(current_user)
|
2014-05-23 09:16:03 -04:00
|
|
|
execute_hooks(issue, 'open')
|
2014-04-02 06:38:35 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
issue
|
|
|
|
end
|
2016-07-21 19:11:53 -04:00
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def spam_check_service
|
|
|
|
SpamCheckService.new(project, current_user, params)
|
|
|
|
end
|
2016-07-27 20:03:06 -04:00
|
|
|
|
|
|
|
def user_agent_detail_service(issue, request)
|
|
|
|
UserAgentDetailService.new(issue, request)
|
|
|
|
end
|
2014-04-02 06:38:35 -04:00
|
|
|
end
|
|
|
|
end
|