2
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2025-09-06 09:10:25 +08:00

refactor validators

add a new setting for min pm body length
use that setting for flags
scale entropy check down for pms
This commit is contained in:
Sam 2013-06-13 18:18:17 +10:00
parent b027f7d8da
commit f7de9f17d5
12 changed files with 91 additions and 23 deletions

View file

@ -10,8 +10,13 @@ class TextSentinel
@text = text.to_s.encode('UTF-8', invalid: :replace, undef: :replace, replace: '')
end
def self.body_sentinel(text)
TextSentinel.new(text, min_entropy: SiteSetting.body_min_entropy)
def self.body_sentinel(text, opts={})
entropy = SiteSetting.body_min_entropy
if opts[:private_message]
scale_entropy = SiteSetting.min_private_message_post_length.to_f / SiteSetting.min_post_length.to_f
entropy = (entropy * scale_entropy).to_i
end
TextSentinel.new(text, min_entropy: entropy)
end
def self.title_sentinel(text)