debian-mirror-gitlab/app/services/create_snippet_service.rb

20 lines
439 B
Ruby
Raw Normal View History

2015-04-26 12:48:37 +05:30
class CreateSnippetService < BaseService
def execute
2016-08-24 12:49:21 +05:30
snippet = if project
project.snippets.build(params)
else
PersonalSnippet.new(params)
end
2015-04-26 12:48:37 +05:30
2016-06-02 11:05:42 +05:30
unless Gitlab::VisibilityLevel.allowed_for?(current_user, params[:visibility_level])
2015-04-26 12:48:37 +05:30
deny_visibility_level(snippet)
return snippet
end
snippet.author = current_user
snippet.save
snippet
end
end