summaryrefslogtreecommitdiff
path: root/lib/api/snippets.rb
diff options
context:
space:
mode:
authorOswaldo Ferreira <oswaldo@gitlab.com>2017-02-14 17:07:11 -0200
committerOswaldo Ferreira <oswluizf@gmail.com>2017-02-21 13:32:49 -0300
commit2ace39f2420abf018ceef6aaad52e4917bcbab7d (patch)
treecae709a6381c80c70af5da459c3ffa992593843d /lib/api/snippets.rb
parent881529495379505542033bf7fb0d91cdc5b51e8d (diff)
downloadgitlab-ce-2ace39f2420abf018ceef6aaad52e4917bcbab7d.tar.gz
Spam check and reCAPTCHA improvements28093-snippet-and-issue-spam-check-on-edit
Diffstat (limited to 'lib/api/snippets.rb')
-rw-r--r--lib/api/snippets.rb7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/api/snippets.rb b/lib/api/snippets.rb
index eb9ece49e7f..ac03fbd2a3d 100644
--- a/lib/api/snippets.rb
+++ b/lib/api/snippets.rb
@@ -67,6 +67,8 @@ module API
attrs = declared_params(include_missing: false).merge(request: request, api: true)
snippet = CreateSnippetService.new(nil, current_user, attrs).execute
+ render_spam_error! if snippet.spam?
+
if snippet.persisted?
present snippet, with: Entities::PersonalSnippet
else
@@ -93,9 +95,12 @@ module API
return not_found!('Snippet') unless snippet
authorize! :update_personal_snippet, snippet
- attrs = declared_params(include_missing: false)
+ attrs = declared_params(include_missing: false).merge(request: request, api: true)
UpdateSnippetService.new(nil, current_user, snippet, attrs).execute
+
+ render_spam_error! if snippet.spam?
+
if snippet.persisted?
present snippet, with: Entities::PersonalSnippet
else