Fix dmail failures when akismet isn't configured.

This commit is contained in:
evazion
2017-11-25 21:26:59 -06:00
parent b62b16b5a2
commit 127e4e385b
4 changed files with 16 additions and 11 deletions

View File

@@ -30,6 +30,12 @@ class Dmail < ApplicationRecord
def creator_ip_addr_str
creator_ip_addr.to_s
end
def spam?(sender = CurrentUser.user)
return false if Danbooru.config.rakismet_key.blank?
return false if sender.is_gold?
super()
end
end
module AddressMethods
@@ -52,12 +58,7 @@ class Dmail < ApplicationRecord
def initialize_attributes
self.from_id ||= CurrentUser.id
self.creator_ip_addr ||= CurrentUser.ip_addr
if CurrentUser.is_gold?
self.is_spam = false
else
self.is_spam = spam?
end
true
self.is_spam = spam?(CurrentUser.user)
end
end