2015-03-07 14:47:06 -05:00
|
|
|
class CreateSnippetService < BaseService
|
|
|
|
def execute
|
2016-07-06 09:26:59 -04:00
|
|
|
snippet = if project
|
|
|
|
project.snippets.build(params)
|
|
|
|
else
|
|
|
|
PersonalSnippet.new(params)
|
|
|
|
end
|
2015-03-07 14:47:06 -05:00
|
|
|
|
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
|