FIX: prevents PM to large groups (#28681)

This commit introduces a new hidden site setting: `group_pm_user_limit`, default to `1000` which will raise an error when attempting to create a PM target a large group.
This commit is contained in:
Joffrey JAFFEUX
2024-09-03 12:08:14 +02:00
committed by GitHub
parent 80b9c280ba
commit e418f7056f
7 changed files with 84 additions and 4 deletions

View File

@ -109,7 +109,18 @@ class TopicCreator
end
topic.reload.topic_allowed_groups.each do |topic_allowed_group|
topic_allowed_group.group.set_message_default_notification_levels!(topic)
group = topic_allowed_group.group
begin
group.set_message_default_notification_levels!(topic)
rescue Group::GroupPmUserLimitExceededError => e
rollback_with!(
topic,
:too_large_group,
group_name: group.name,
limit: SiteSetting.group_pm_user_limit,
)
end
end
end