diff options
Diffstat (limited to 'app/services/spam')
-rw-r--r-- | app/services/spam/ham_service.rb | 2 | ||||
-rw-r--r-- | app/services/spam/mark_as_spam_service.rb | 14 | ||||
-rw-r--r-- | app/services/spam/spam_check_service.rb | 22 |
3 files changed, 19 insertions, 19 deletions
diff --git a/app/services/spam/ham_service.rb b/app/services/spam/ham_service.rb index d0f53eea90c..87069d5cd54 100644 --- a/app/services/spam/ham_service.rb +++ b/app/services/spam/ham_service.rb @@ -23,6 +23,6 @@ module Spam end end - alias_method :spammable, :spam_log + alias_method :target, :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..3269f9d687a 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 + @target = spammable @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 @@ -31,8 +31,8 @@ module Spam # Otherwise, it goes to Akismet for spam check. # If so, it assigns 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 } ) |