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)
|
2016-07-30 00:18:32 -04:00
|
|
|
@request = params.delete(:request)
|
|
|
|
@api = params.delete(:api)
|
|
|
|
@issue = project.issues.new(params)
|
|
|
|
@issue.author = params[:author] || current_user
|
2014-04-02 06:38:35 -04:00
|
|
|
|
2016-08-09 13:43:47 -04:00
|
|
|
@issue.spam = spam_service.check(@api)
|
2016-07-18 19:17:43 -04:00
|
|
|
|
2016-07-30 00:18:32 -04:00
|
|
|
if @issue.save
|
|
|
|
@issue.update_attributes(label_ids: label_params)
|
|
|
|
notification_service.new_issue(@issue, current_user)
|
|
|
|
todo_service.new_issue(@issue, current_user)
|
|
|
|
event_service.open_issue(@issue, current_user)
|
|
|
|
user_agent_detail_service.create
|
|
|
|
@issue.create_cross_references!(current_user)
|
|
|
|
execute_hooks(@issue, 'open')
|
2014-04-02 06:38:35 -04:00
|
|
|
end
|
|
|
|
|
2016-07-30 00:18:32 -04:00
|
|
|
@issue
|
2014-04-02 06:38:35 -04:00
|
|
|
end
|
2016-07-21 19:11:53 -04:00
|
|
|
|
|
|
|
private
|
|
|
|
|
2016-08-05 18:10:08 -04:00
|
|
|
def spam_service
|
2016-08-09 13:43:47 -04:00
|
|
|
SpamService.new(@issue, @request)
|
2016-07-21 19:11:53 -04:00
|
|
|
end
|
2016-07-27 20:03:06 -04:00
|
|
|
|
2016-07-30 00:18:32 -04:00
|
|
|
def user_agent_detail_service
|
|
|
|
UserAgentDetailService.new(@issue, @request)
|
2016-07-27 20:03:06 -04:00
|
|
|
end
|
2014-04-02 06:38:35 -04:00
|
|
|
end
|
|
|
|
end
|