summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorLin Jen-Shin <godfat@godfat.org>2016-07-28 14:08:45 +0800
committerLin Jen-Shin <godfat@godfat.org>2016-07-28 14:08:45 +0800
commit9370bb231bf7a294d94c2fb62faf482627a0ae7a (patch)
treea307ae0b29d9ea9162364583a32b974e4a21fdc4 /lib
parentbac99f909a57501e69df75e222888f157fc34f17 (diff)
parent17be364d072298f42d77fd22189bf9289b7cda2e (diff)
downloadgitlab-ce-9370bb231bf7a294d94c2fb62faf482627a0ae7a.tar.gz
Merge remote-tracking branch 'upstream/master' into new-issue-by-email
* upstream/master: (45 commits) Replace reject_blocked with reject_blocked! in callbacks. Fix Project#to_param to keep invalid project suitable for use in URLs Update CHANGELOG Add feature specs for edit project settings Fix renaming repository when name contains invalid chars under settings Change requests_profiles resource constraint to catch virtually any file Allow skipping users in autocomplete Fix typo in CHANGELOG Update CHANGELOG Respective cache is now expired when creating a new branch Update CHANGELOG Unify HTML format in static error pages Make error pages responsive design Move color-logic into HipchatService#HipchatService Depened on exact version of SimpleCov when patched Refactor spam validation to a concern that can be easily reused and improve legibility in `SpamCheckService` Refactor `SpamCheckService` to make it cleaner and clearer. Submit all issues on public projects to Akismet if enabled. Submit new issues created via the WebUI by non project members to Akismet for spam check. Upgrade Bullet from 5.0.0 to 5.2.0. ...
Diffstat (limited to 'lib')
-rw-r--r--lib/api/issues.rb19
-rw-r--r--lib/gitlab/akismet_helper.rb4
-rw-r--r--lib/tasks/test.rake2
3 files changed, 6 insertions, 19 deletions
diff --git a/lib/api/issues.rb b/lib/api/issues.rb
index c588103e517..c4d3134da6c 100644
--- a/lib/api/issues.rb
+++ b/lib/api/issues.rb
@@ -21,17 +21,6 @@ module API
def filter_issues_milestone(issues, milestone)
issues.includes(:milestone).where('milestones.title' => milestone)
end
-
- def create_spam_log(project, current_user, attrs)
- params = attrs.merge({
- source_ip: client_ip(env),
- user_agent: user_agent(env),
- noteable_type: 'Issue',
- via_api: true
- })
-
- ::CreateSpamLogService.new(project, current_user, params).execute
- end
end
resource :issues do
@@ -168,15 +157,13 @@ module API
end
project = user_project
- 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)
+ 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
- issue = ::Issues::CreateService.new(project, current_user, attrs).execute
-
if issue.valid?
# 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
diff --git a/lib/gitlab/akismet_helper.rb b/lib/gitlab/akismet_helper.rb
index 04676fdb748..207736b59db 100644
--- a/lib/gitlab/akismet_helper.rb
+++ b/lib/gitlab/akismet_helper.rb
@@ -17,8 +17,8 @@ module Gitlab
env['HTTP_USER_AGENT']
end
- def check_for_spam?(project, user)
- akismet_enabled? && !project.team.member?(user)
+ def check_for_spam?(project)
+ akismet_enabled? && project.public?
end
def is_spam?(environment, user, text)
diff --git a/lib/tasks/test.rake b/lib/tasks/test.rake
index 21c0e5f1d41..d3dcbd2c29b 100644
--- a/lib/tasks/test.rake
+++ b/lib/tasks/test.rake
@@ -7,5 +7,5 @@ end
unless Rails.env.production?
desc "GitLab | Run all tests on CI with simplecov"
- task test_ci: [:rubocop, :brakeman, 'teaspoon', :spinach, :spec]
+ task test_ci: [:rubocop, :brakeman, :teaspoon, :spinach, :spec]
end