mirror of
https://github.com/discourse/discourse.git
synced 2025-05-21 18:12:32 +08:00
New users can only post newuser_max_replies_per_topic
times per topic.
This commit is contained in:
@ -5,6 +5,7 @@ class Validators::PostValidator < ActiveModel::Validator
|
||||
presence(record)
|
||||
stripped_length(record)
|
||||
raw_quality(record)
|
||||
max_posts_validator(record)
|
||||
max_mention_validator(record)
|
||||
max_images_validator(record)
|
||||
max_attachments_validator(record)
|
||||
@ -40,6 +41,12 @@ class Validators::PostValidator < ActiveModel::Validator
|
||||
end
|
||||
end
|
||||
|
||||
def max_posts_validator(post)
|
||||
if post.acting_user.present? && post.acting_user.posted_too_much_in_topic?(post.topic_id)
|
||||
post.errors.add(:base, I18n.t(:too_many_replies))
|
||||
end
|
||||
end
|
||||
|
||||
# Ensure new users can not put too many images in a post
|
||||
def max_images_validator(post)
|
||||
add_error_if_count_exceeded(post, :too_many_images, post.image_count, SiteSetting.newuser_max_images) unless acting_user_is_trusted?(post)
|
||||
|
Reference in New Issue
Block a user