discourse-ai/lib/configuration/spam_detection_validator.rb
Keegan George 297c64c3b8
DEV: Unhide spam detection setting (#1374)
## 🔍 Overview
We want to unhide `ai_spam_detection_enabled` setting so that we can retain staff action log features. However, we also want to ensure users cannot enable spam detection without having `AiModerationSetting.spam` present in the database.

In this update we unhide the setting, but also add a validator to ensure the necessary configuration is in place before allowing the setting to be enabled.
2025-05-28 07:50:56 -07:00

23 lines
431 B
Ruby

# frozen_string_literal: true
module DiscourseAi
module Configuration
class SpamDetectionValidator
def initialize(opts = {})
@opts = opts
end
def valid_value?(val)
return true if Rails.env.test?
return true if AiModerationSetting.spam
false
end
def error_message
I18n.t("discourse_ai.spam_detection.configuration_missing")
end
end
end
end