2
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2025-09-05 08:59:27 +08:00

FEATURE: new site setting to limit message recipients

New site setting `max_allowed_message_recipients` to limit message
recipients

https://meta.discourse.org/t/one-of-my-users-just-group-messaged-100-other-user-with-a-spam-offer/65612/7?u=techapj
This commit is contained in:
Arpit Jalan 2017-07-05 22:39:45 +05:30
parent 59e5911b02
commit 7cffbc8ba8
4 changed files with 65 additions and 0 deletions

View file

@ -92,6 +92,12 @@ class PostCreator
return false
end
# Make sure max_allowed_message_recipients setting is respected
if @opts[:target_usernames].present? && !skip_validations? && !@user.staff?
errors[:base] << I18n.t(:max_pm_recepients, recipients_limit: SiteSetting.max_allowed_message_recipients) if @opts[:target_usernames].split(',').length > SiteSetting.max_allowed_message_recipients
return false if errors[:base].present?
end
# Make sure none of the users have muted the creator
names = @opts[:target_usernames]
if names.present? && !skip_validations? && !@user.staff?