2015-03-07 14:47:06 -05:00
|
|
|
class CreateSnippetService < BaseService
|
|
|
|
def execute
|
|
|
|
if project.nil?
|
|
|
|
snippet = PersonalSnippet.new(params)
|
|
|
|
else
|
|
|
|
snippet = project.snippets.build(params)
|
|
|
|
end
|
|
|
|
|
2016-03-20 16:03:53 -04:00
|
|
|
unless Gitlab::VisibilityLevel.allowed_for?(current_user, params[:visibility_level])
|
2015-03-07 14:47:06 -05:00
|
|
|
deny_visibility_level(snippet)
|
|
|
|
return snippet
|
|
|
|
end
|
|
|
|
|
|
|
|
snippet.author = current_user
|
|
|
|
|
|
|
|
snippet.save
|
|
|
|
snippet
|
|
|
|
end
|
|
|
|
end
|