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
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-02-12 12:09:11 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-02-12 12:09:11 +0300
commit0388886f9439fa93efea29a159522aec5643f7c8 (patch)
tree9a4b2305088e62a9745ce598b45aa34e39e59642 /app/services/spam
parent8c9dc985b90c353b33cb829caf51f8320171bc15 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/services/spam')
-rw-r--r--app/services/spam/ham_service.rb16
-rw-r--r--app/services/spam/mark_as_spam_service.rb14
-rw-r--r--app/services/spam/spam_check_service.rb26
3 files changed, 27 insertions, 29 deletions
diff --git a/app/services/spam/ham_service.rb b/app/services/spam/ham_service.rb
index d0f53eea90c..cedb9f02f3d 100644
--- a/app/services/spam/ham_service.rb
+++ b/app/services/spam/ham_service.rb
@@ -4,25 +4,23 @@ module Spam
class HamService
include AkismetMethods
- attr_accessor :spam_log, :options
+ attr_accessor :target, :options
- def initialize(spam_log)
- @spam_log = spam_log
- @user = spam_log.user
+ def initialize(target)
+ @target = target
+ @user = target.user
@options = {
- ip_address: spam_log.source_ip,
- user_agent: spam_log.user_agent
+ ip_address: target.source_ip,
+ user_agent: target.user_agent
}
end
def execute
if akismet.submit_ham
- spam_log.update_attribute(:submitted_as_ham, true)
+ target.update_attribute(:submitted_as_ham, true)
else
false
end
end
-
- alias_method :spammable, :spam_log
end
end
diff --git a/app/services/spam/mark_as_spam_service.rb b/app/services/spam/mark_as_spam_service.rb
index 0ebcf17927a..ed5e674d8e9 100644
--- a/app/services/spam/mark_as_spam_service.rb
+++ b/app/services/spam/mark_as_spam_service.rb
@@ -4,21 +4,21 @@ module Spam
class MarkAsSpamService
include ::AkismetMethods
- attr_accessor :spammable, :options
+ attr_accessor :target, :options
- def initialize(spammable:)
- @spammable = spammable
+ def initialize(target:)
+ @target = target
@options = {}
- @options[:ip_address] = @spammable.ip_address
- @options[:user_agent] = @spammable.user_agent
+ @options[:ip_address] = @target.ip_address
+ @options[:user_agent] = @target.user_agent
end
def execute
- return unless spammable.submittable_as_spam?
+ return unless target.submittable_as_spam?
return unless akismet.submit_spam
- spammable.user_agent_detail.update_attribute(:submitted, true)
+ target.user_agent_detail.update_attribute(:submitted, true)
end
end
end
diff --git a/app/services/spam/spam_check_service.rb b/app/services/spam/spam_check_service.rb
index d19ef03976f..a922b0d96e7 100644
--- a/app/services/spam/spam_check_service.rb
+++ b/app/services/spam/spam_check_service.rb
@@ -4,11 +4,11 @@ module Spam
class SpamCheckService
include AkismetMethods
- attr_accessor :spammable, :request, :options
+ attr_accessor :target, :request, :options
attr_reader :spam_log
- def initialize(spammable:, request:)
- @spammable = spammable
+ def initialize(target:, request:)
+ @target = target
@request = request
@options = {}
@@ -17,8 +17,8 @@ module Spam
@options[:user_agent] = @request.env['HTTP_USER_AGENT']
@options[:referrer] = @request.env['HTTP_REFERRER']
else
- @options[:ip_address] = @spammable.ip_address
- @options[:user_agent] = @spammable.user_agent
+ @options[:ip_address] = @target.ip_address
+ @options[:user_agent] = @target.user_agent
end
end
@@ -29,10 +29,10 @@ module Spam
SpamLog.verify_recaptcha!(user_id: user_id, id: spam_log_id)
else
# Otherwise, it goes to Akismet for spam check.
- # If so, it assigns spammable object as "spam" and creates a SpamLog record.
+ # If so, it assigns target spammable object as "spam" and creates a SpamLog record.
possible_spam = check(api)
- spammable.spam = possible_spam unless spammable.allow_possible_spam?
- spammable.spam_log = spam_log
+ target.spam = possible_spam unless target.allow_possible_spam?
+ target.spam_log = spam_log
end
end
@@ -48,18 +48,18 @@ module Spam
end
def check_for_spam?
- spammable.check_for_spam?
+ target.check_for_spam?
end
def create_spam_log(api)
@spam_log = SpamLog.create!(
{
- user_id: spammable.author_id,
- title: spammable.spam_title,
- description: spammable.spam_description,
+ user_id: target.author_id,
+ title: target.spam_title,
+ description: target.spam_description,
source_ip: options[:ip_address],
user_agent: options[:user_agent],
- noteable_type: spammable.class.to_s,
+ noteable_type: target.class.to_s,
via_api: api
}
)