... ... @@ -4,11 +4,11 @@ module Spam
class SpamCheckService
include AkismetMethods
attr_accessor :target , :request , :options
attr_accessor :spammable , :request , :options
attr_reader :spam_log
def initialize ( target :, request :)
@target = target
def initialize ( spammable :, request :)
@spammable = 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 ] = @target . ip_address
@options [ :user_agent ] = @target . user_agent
@options [ :ip_address ] = @spammable . ip_address
@options [ :user_agent ] = @spammable . 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 target spammable object as "spam" and creates a SpamLog record.
# If so, it assigns spammable object as "spam" and creates a SpamLog record.
possible_spam = check ( api )
target . spam = possible_spam unless target . allow_possible_spam?
target . spam_log = spam_log
spammable . spam = possible_spam unless spammable . allow_possible_spam?
spammable . spam_log = spam_log
end
end
... ... @@ -48,18 +48,18 @@ module Spam
end
def check_for_spam?
target . check_for_spam?
spammable . check_for_spam?
end
def create_spam_log ( api )
@spam_log = SpamLog . create! (
{
user_id: target . author_id ,
title: target . spam_title ,
description: target . spam_description ,
user_id: spammable . author_id ,
title: spammable . spam_title ,
description: spammable . spam_description ,
source_ip: options [ :ip_address ],
user_agent: options [ :user_agent ],
noteable_type: target . class . to_s ,
noteable_type: spammable . class . to_s ,
via_api: api
}
)
... ...
... ...