gitlab-org--gitlab-foss/app/services/create_snippet_service.rb

29 lines
607 B
Ruby
Raw Normal View History

class CreateSnippetService < BaseService
2017-02-14 14:07:11 -05:00
include SpamCheckService
def execute
2017-02-14 14:07:11 -05:00
filter_spam_check_params
snippet = if project
project.snippets.build(params)
else
PersonalSnippet.new(params)
end
2016-03-20 16:03:53 -04:00
unless Gitlab::VisibilityLevel.allowed_for?(current_user, params[:visibility_level])
deny_visibility_level(snippet)
return snippet
end
snippet.author = current_user
2017-02-14 14:07:11 -05:00
spam_check(snippet, current_user)
if snippet.save
2017-02-14 14:07:11 -05:00
UserAgentDetailService.new(snippet, @request).create
end
snippet
end
end