Merge pull request #3401 from evazion/fix-akismet-integration
Fix dmail failures when akismet isn't configured.
This commit is contained in:
@@ -30,6 +30,12 @@ class Dmail < ApplicationRecord
|
|||||||
def creator_ip_addr_str
|
def creator_ip_addr_str
|
||||||
creator_ip_addr.to_s
|
creator_ip_addr.to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def spam?(sender = CurrentUser.user)
|
||||||
|
return false if Danbooru.config.rakismet_key.blank?
|
||||||
|
return false if sender.is_gold?
|
||||||
|
super()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
module AddressMethods
|
module AddressMethods
|
||||||
@@ -52,12 +58,7 @@ class Dmail < ApplicationRecord
|
|||||||
def initialize_attributes
|
def initialize_attributes
|
||||||
self.from_id ||= CurrentUser.id
|
self.from_id ||= CurrentUser.id
|
||||||
self.creator_ip_addr ||= CurrentUser.ip_addr
|
self.creator_ip_addr ||= CurrentUser.ip_addr
|
||||||
if CurrentUser.is_gold?
|
self.is_spam = spam?(CurrentUser.user)
|
||||||
self.is_spam = false
|
|
||||||
else
|
|
||||||
self.is_spam = spam?
|
|
||||||
end
|
|
||||||
true
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -30,11 +30,6 @@ module Danbooru
|
|||||||
config.x.git_hash = nil
|
config.x.git_hash = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
if ENV["DANBOORU_RAKISMET_KEY"]
|
|
||||||
config.rakismet.key = ENV["DANBOORU_RAKISMET_KEY"]
|
|
||||||
config.rakismet.url = ENV["DANBOORU_RAKISMET_URL"]
|
|
||||||
end
|
|
||||||
|
|
||||||
config.after_initialize do
|
config.after_initialize do
|
||||||
Rails.application.routes.default_url_options = {
|
Rails.application.routes.default_url_options = {
|
||||||
host: Danbooru.config.hostname,
|
host: Danbooru.config.hostname,
|
||||||
|
|||||||
@@ -619,6 +619,13 @@ module Danbooru
|
|||||||
|
|
||||||
def aws_sqs_cropper_url
|
def aws_sqs_cropper_url
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Akismet API key. Used for Dmail spam detection. http://akismet.com/signup/
|
||||||
|
def rakismet_key
|
||||||
|
end
|
||||||
|
|
||||||
|
def rakismet_url
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class EnvironmentConfiguration
|
class EnvironmentConfiguration
|
||||||
|
|||||||
2
config/initializers/rakismet.rb
Normal file
2
config/initializers/rakismet.rb
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
Rails.application.config.rakismet.key = Danbooru.config.rakismet_key
|
||||||
|
Rails.application.config.rakismet.url = Danbooru.config.rakismet_url
|
||||||
Reference in New Issue
Block a user