Add custom score and last_activity method to determine if safe or not
parent
475b749cf6
commit
6571e9bef5
|
@ -6,7 +6,7 @@ require "project_honeypot/rack/forbidden"
|
|||
|
||||
module ProjectHoneypot
|
||||
class << self
|
||||
attr_accessor :api_key
|
||||
attr_accessor :api_key, :score, :last_activity
|
||||
|
||||
def api_key
|
||||
raise "ProjectHoneypot really needs its api_key set to work" unless @api_key
|
||||
|
|
|
@ -7,8 +7,16 @@ module ProjectHoneypot
|
|||
process_score(honeypot_response)
|
||||
end
|
||||
|
||||
def safe?
|
||||
@safe
|
||||
def safe?(hash = {})
|
||||
score = hash[:score] || ProjectHoneypot.score
|
||||
last_activity = hash[:last_activity] || ProjectHoneypot.last_activity
|
||||
|
||||
@safe ||
|
||||
!(
|
||||
last_activity.nil? && score.nil? ||
|
||||
!score.nil? && self.score > score ||
|
||||
!last_activity.nil? && self.last_activity > last_activity
|
||||
)
|
||||
end
|
||||
|
||||
def comment_spammer?
|
||||
|
|
Loading…
Reference in New Issue