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

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDouglas Barbosa Alexandre <dbalexandre@gmail.com>2016-01-26 23:08:20 +0300
committerDouglas Barbosa Alexandre <dbalexandre@gmail.com>2016-02-02 16:25:44 +0300
commita2bbf004779db402e67a918db893c166502f5050 (patch)
tree1ad63ff44c8071630e7aff93ebddb0c644b877af /lib
parent62cad887ea695d40afee894089f894ee398cf98a (diff)
Refactor spam filtering on issues API
Diffstat (limited to 'lib')
-rw-r--r--lib/api/issues.rb15
1 files changed, 8 insertions, 7 deletions
diff --git a/lib/api/issues.rb b/lib/api/issues.rb
index cdadd13c13a..252744515da 100644
--- a/lib/api/issues.rb
+++ b/lib/api/issues.rb
@@ -23,11 +23,13 @@ module API
end
def create_spam_log(project, current_user, attrs)
- params = attrs.dup
- params[:source_ip] = env['REMOTE_ADDR']
- params[:user_agent] = env['HTTP_USER_AGENT']
- params[:noteable_type] = 'Issue'
- params[:via_api] = true
+ params = attrs.merge({
+ source_ip: env['REMOTE_ADDR'],
+ user_agent: env['HTTP_USER_AGENT'],
+ noteable_type: 'Issue',
+ via_api: true
+ })
+
::CreateSpamLogService.new(project, current_user, params).execute
end
end
@@ -126,8 +128,7 @@ module API
end
project = user_project
- text = attrs[:title]
- text += "\n#{attrs[:description]}" if attrs[:description].present?
+ text = [attrs[:title], attrs[:description]].reject(&:blank?).join("\n")
if check_for_spam?(project, current_user) && is_spam?(env, current_user, text)
create_spam_log(project, current_user, attrs)