New users can only post newuser_max_replies_per_topic times per topic.

This commit is contained in:
Robin Ward
2013-12-19 13:45:55 -05:00
parent 39e711783d
commit 1cac9fa257
8 changed files with 68 additions and 1 deletions

View File

@ -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)