Welcome to mirror list, hosted at ThFree Co, Russian Federation.

create_snippet_service.rb « services « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 101a3df5eee44f8cdaa6151f88f16bb28582d2b5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
class CreateSnippetService < BaseService
  def execute
    if project.nil?
      snippet = PersonalSnippet.new(params)
    else
      snippet = project.snippets.build(params)
    end

    unless Gitlab::VisibilityLevel.allowed_for?(current_user,
                                                params[:visibility_level])
      deny_visibility_level(snippet)
      return snippet
    end

    snippet.author = current_user

    snippet.save
    snippet
  end
end