c63194ce6f
Apply the same spam checks to public snippets (either personal snippets that are public, or public snippets on public projects) as to issues on public projects.
26 lines
642 B
Ruby
26 lines
642 B
Ruby
class CreateSnippetService < BaseService
|
|
def execute
|
|
request = params.delete(:request)
|
|
api = params.delete(:api)
|
|
|
|
snippet = if project
|
|
project.snippets.build(params)
|
|
else
|
|
PersonalSnippet.new(params)
|
|
end
|
|
|
|
unless Gitlab::VisibilityLevel.allowed_for?(current_user, params[:visibility_level])
|
|
deny_visibility_level(snippet)
|
|
return snippet
|
|
end
|
|
|
|
snippet.author = current_user
|
|
snippet.spam = SpamService.new(snippet, request).check(api)
|
|
|
|
if snippet.save
|
|
UserAgentDetailService.new(snippet, request).create
|
|
end
|
|
|
|
snippet
|
|
end
|
|
end
|