mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 16:21:18 +08:00
FEATURE: Allow posting a link with topics
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user