gitlab-org--gitlab-foss/app/services/search/snippet_service.rb
Douwe Maan ad309f5d11 Merge branch 'snippets-finder-visibility' into 'security'
Refactor snippets finder & dont return internal snippets for external users

See merge request !2094
2017-05-10 16:48:18 +02:00

19 lines
430 B
Ruby

module Search
class SnippetService
attr_accessor :current_user, :params
def initialize(user, params)
@current_user, @params = user, params.dup
end
def execute
snippets = SnippetsFinder.new(current_user).execute
Gitlab::SnippetSearchResults.new(snippets, params[:search])
end
def scope
@scope ||= %w[snippet_titles].delete(params[:scope]) { 'snippet_blobs' }
end
end
end