FEATURE: Allow posting a link with topics

This commit is contained in:
Erick Guan
2016-12-05 13:31:43 +01:00
parent e82084405e
commit 52763f5115
50 changed files with 503 additions and 77 deletions

View File

@ -10,8 +10,7 @@ class Validators::PostValidator < ActiveModel::Validator
return if record.acting_user.try(:staged?)
return if record.acting_user.try(:admin?) && Discourse.static_doc_topic_ids.include?(record.topic_id)
stripped_length(record)
raw_quality(record)
post_body_validator(record)
max_posts_validator(record)
max_mention_validator(record)
max_images_validator(record)
@ -21,8 +20,6 @@ class Validators::PostValidator < ActiveModel::Validator
end
def presence(post)
post.errors.add(:raw, :blank, options) if post.raw.blank?
unless options[:skip_topic]
post.errors.add(:topic_id, :blank, options) if post.topic_id.blank?
end
@ -32,6 +29,12 @@ class Validators::PostValidator < ActiveModel::Validator
end
end
def post_body_validator(post)
return if options[:skip_post_body]
stripped_length(post)
raw_quality(post)
end
def stripped_length(post)
range = if private_message?(post)
# private message