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/app
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-07-20 09:08:37 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-07-20 09:08:37 +0300
commit1ad2f1981f05721d92d04c490cfc0f234737fec1 (patch)
tree2f7cb8bff250153f12d6db1a35a17eed81589b25 /app
parent93c966ae2abeb481cfa894351b74f954e406582d (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
-rw-r--r--app/models/concerns/spammable.rb2
-rw-r--r--app/models/issue.rb4
-rw-r--r--app/models/snippet.rb2
-rw-r--r--app/services/spam/spam_action_service.rb4
4 files changed, 6 insertions, 6 deletions
diff --git a/app/models/concerns/spammable.rb b/app/models/concerns/spammable.rb
index 2daea388939..4901cd832ff 100644
--- a/app/models/concerns/spammable.rb
+++ b/app/models/concerns/spammable.rb
@@ -111,7 +111,7 @@ module Spammable
end
# Override in Spammable if further checks are necessary
- def check_for_spam?
+ def check_for_spam?(user:)
true
end
diff --git a/app/models/issue.rb b/app/models/issue.rb
index 00fcba5298a..d1ef84a8a97 100644
--- a/app/models/issue.rb
+++ b/app/models/issue.rb
@@ -437,10 +437,10 @@ class Issue < ApplicationRecord
user, project.external_authorization_classification_label)
end
- def check_for_spam?
+ def check_for_spam?(user:)
# content created via support bots is always checked for spam, EVEN if
# the issue is not publicly visible and/or confidential
- return true if author.support_bot? && spammable_attribute_changed?
+ return true if user.support_bot? && spammable_attribute_changed?
# Only check for spam on issues which are publicly visible (and thus indexed in search engines)
return false unless publicly_visible?
diff --git a/app/models/snippet.rb b/app/models/snippet.rb
index 68957dd6b22..dd76f2c3c84 100644
--- a/app/models/snippet.rb
+++ b/app/models/snippet.rb
@@ -246,7 +246,7 @@ class Snippet < ApplicationRecord
notes.includes(:author)
end
- def check_for_spam?
+ def check_for_spam?(user:)
visibility_level_changed?(to: Snippet::PUBLIC) ||
(public? && (title_changed? || content_changed?))
end
diff --git a/app/services/spam/spam_action_service.rb b/app/services/spam/spam_action_service.rb
index ec16ce19cf6..2a28b66f09b 100644
--- a/app/services/spam/spam_action_service.rb
+++ b/app/services/spam/spam_action_service.rb
@@ -28,7 +28,7 @@ module Spam
ServiceResponse.success(message: "CAPTCHA successfully verified")
else
return ServiceResponse.success(message: 'Skipped spam check because user was allowlisted') if allowlisted?(user)
- return ServiceResponse.success(message: 'Skipped spam check because it was not required') unless check_for_spam?
+ return ServiceResponse.success(message: 'Skipped spam check because it was not required') unless check_for_spam?(user: user)
perform_spam_service_check
ServiceResponse.success(message: "Spam check performed. Check #{target.class.name} spammable model for any errors or CAPTCHA requirement")
@@ -94,7 +94,7 @@ module Spam
def create_spam_log
@spam_log = SpamLog.create!(
{
- user_id: target.author_id,
+ user_id: user.id,
title: target.spam_title,
description: target.spam_description,
source_ip: spam_params.ip_address,