diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/api/issues.rb | 12 | ||||
-rw-r--r-- | lib/gitlab/akismet_helper.rb | 11 |
2 files changed, 5 insertions, 18 deletions
diff --git a/lib/api/issues.rb b/lib/api/issues.rb index 21b9eb367e7..c4d3134da6c 100644 --- a/lib/api/issues.rb +++ b/lib/api/issues.rb @@ -158,15 +158,13 @@ module API project = user_project - issue = ::Issues::CreateService.new(project, current_user, attrs.merge({ request: request })).execute + issue = ::Issues::CreateService.new(project, current_user, attrs.merge(request: request, api: true)).execute + + if issue.spam? + render_api_error!({ error: 'Spam detected' }, 400) + end if issue.valid? - # Need to check if id is nil here, because if issue is spam, errors - # get added, but Rails still thinks it's valid, but it is never saved - # so id will be nil - if issue.id.nil? - render_api_error!({ error: 'Spam detected' }, 400) - end # Find or create labels and attach to issue. Labels are valid because # we already checked its name, so there can't be an error here if params[:labels].present? diff --git a/lib/gitlab/akismet_helper.rb b/lib/gitlab/akismet_helper.rb index fc1fbc5b600..207736b59db 100644 --- a/lib/gitlab/akismet_helper.rb +++ b/lib/gitlab/akismet_helper.rb @@ -43,16 +43,5 @@ module Gitlab false end end - - def create_spam_log(project, current_user, attrs, env, api: true) - params = attrs.merge({ - source_ip: client_ip(env), - user_agent: user_agent(env), - noteable_type: 'Issue', - via_api: api - }) - - ::CreateSpamLogService.new(project, current_user, params).execute - end end end |