FIX: Amend broken group automatic member dialog (#31854)

When creating or editing a group, we are meant to show a dialog telling the admin how many members will be automatically added.
This commit is contained in:
Ted Johansson
2025-03-18 19:37:37 +08:00
committed by GitHub
parent fb5cdb1da4
commit 1a7303a35e
13 changed files with 219 additions and 36 deletions

View File

@ -1,6 +1,8 @@
# frozen_string_literal: true
class Admin::GroupsController < Admin::StaffController
MAX_AUTO_MEMBERSHIP_DOMAINS_LOOKUP = 10
def create
guardian.ensure_can_create_group!
@ -94,6 +96,15 @@ class Admin::GroupsController < Admin::StaffController
domains -= existing_domains
end
if domains.size > MAX_AUTO_MEMBERSHIP_DOMAINS_LOOKUP
raise Discourse::InvalidParameters.new(
I18n.t(
"groups.errors.counting_too_many_email_domains",
count: MAX_AUTO_MEMBERSHIP_DOMAINS_LOOKUP,
),
)
end
user_count = Group.automatic_membership_users(domains.join("|")).count
end