mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
New users can only post newuser_max_replies_per_topic times per topic.
This commit is contained in:
@@ -7,6 +7,7 @@ class ComposerMessagesFinder
|
||||
|
||||
def find
|
||||
check_education_message ||
|
||||
check_new_user_many_replies ||
|
||||
check_avatar_notification ||
|
||||
check_sequential_replies ||
|
||||
check_dominating_topic
|
||||
@@ -32,6 +33,12 @@ class ComposerMessagesFinder
|
||||
nil
|
||||
end
|
||||
|
||||
# New users have a limited number of replies in a topic
|
||||
def check_new_user_many_replies
|
||||
return unless replying? && @user.posted_too_much_in_topic?(@details[:topic_id])
|
||||
{templateName: 'composer/education', body: PrettyText.cook(I18n.t('education.too_many_replies', newuser_max_replies_per_topic: SiteSetting.newuser_max_replies_per_topic)) }
|
||||
end
|
||||
|
||||
# Should a user be contacted to update their avatar?
|
||||
def check_avatar_notification
|
||||
|
||||
|
||||
@@ -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