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

@@ -5,6 +5,7 @@ require_dependency 'post_revisor'
require_dependency 'enum'
require_dependency 'trashable'
require_dependency 'post_analyzer'
require_dependency 'validators/post_validator'
require 'archetype'
require 'digest/sha1'
@@ -17,7 +18,6 @@ class Post < ActiveRecord::Base
rate_limit
belongs_to :user
belongs_to :topic, counter_cache: :posts_count
belongs_to :reply_to_user, class_name: "User"
@@ -28,9 +28,7 @@ class Post < ActiveRecord::Base
has_one :post_search_data
validates_presence_of :raw, :user_id, :topic_id
validates :raw, stripped_length: { in: -> { SiteSetting.post_length } }
validates_with PostValidator
validates_with ::Validators::PostValidator
# We can pass a hash of image sizes when saving to prevent crawling those images
attr_accessor :image_sizes, :quoted_post_numbers, :no_bump, :invalidate_oneboxes

View File

@@ -29,6 +29,7 @@ class SiteSetting < ActiveRecord::Base
client_setting(:polling_interval, 3000)
client_setting(:anon_polling_interval, 30000)
client_setting(:min_post_length, Rails.env.test? ? 5 : 20)
client_setting(:min_private_message_post_length, Rails.env.test? ? 5 : 10)
client_setting(:max_post_length, 16000)
client_setting(:min_topic_title_length, 15)
client_setting(:max_topic_title_length, 255)
@@ -161,7 +162,7 @@ class SiteSetting < ActiveRecord::Base
setting(:enforce_global_nicknames, true)
setting(:discourse_org_access_key, '')
setting(:enable_s3_uploads, false)
setting(:s3_access_key_id, '')
setting(:s3_secret_access_key, '')
@@ -236,6 +237,10 @@ class SiteSetting < ActiveRecord::Base
min_post_length..max_post_length
end
def self.private_message_post_length
min_private_message_post_length..max_post_length
end
def self.homepage
# TODO objectify this
top_menu.split('|')[0].split(',')[0]