FEATURE: new site setting min_first_post_length

This commit is contained in:
Arpit Jalan
2015-03-19 19:47:55 +05:30
parent 89ea125c73
commit b706307ac7
8 changed files with 41 additions and 6 deletions

View File

@ -25,7 +25,17 @@ class Validators::PostValidator < ActiveModel::Validator
end
def stripped_length(post)
range = post.topic.try(:private_message?) ? SiteSetting.private_message_post_length : SiteSetting.post_length
range = if post.topic.try(:private_message?)
# private message
SiteSetting.private_message_post_length
elsif ( post.is_first_post? || (post.topic.present? && post.topic.posts_count == 0) )
# creating/editing first post
SiteSetting.first_post_length
else
# regular post
SiteSetting.post_length
end
Validators::StrippedLengthValidator.validate(post, :raw, post.raw, range)
end