dmails: factor out spam detector service.
This commit is contained in:
@@ -6,8 +6,6 @@ class Dmail < ApplicationRecord
|
||||
AUTOBAN_WINDOW = 24.hours
|
||||
AUTOBAN_DURATION = 3
|
||||
|
||||
include Rakismet::Model
|
||||
|
||||
validates_presence_of :title, :body, on: :create
|
||||
validate :validate_sender_is_not_banned, on: :create
|
||||
|
||||
@@ -20,8 +18,6 @@ class Dmail < ApplicationRecord
|
||||
after_create :update_recipient
|
||||
after_commit :send_email, on: :create
|
||||
|
||||
rakismet_attrs author: proc { from.name }, author_email: proc { from.email }, content: proc { title + "\n\n" + body }, user_ip: proc { creator_ip_addr.to_s }
|
||||
|
||||
concerning :SpamMethods do
|
||||
class_methods do
|
||||
def is_spammer?(user)
|
||||
@@ -41,9 +37,7 @@ class Dmail < ApplicationRecord
|
||||
end
|
||||
|
||||
def spam?
|
||||
return false if Danbooru.config.rakismet_key.blank?
|
||||
return false if from.is_gold?
|
||||
super()
|
||||
SpamDetector.new(self).spam?
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user