mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 22:43:33 +08:00
FEATURE: new site setting min_first_post_length
This commit is contained in:
@ -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
|
||||
|
||||
|
Reference in New Issue
Block a user