From ca48ffccb801eb306006c1950ad24fa98716947a Mon Sep 17 00:00:00 2001 From: Lauryn Menard Date: Mon, 7 Jul 2025 12:20:05 -0400 Subject: [PATCH] realm-create: Update default user email visibility for org_type. When creating a new organization, the new user default for email address visibility is now limited to admins for most organization types. The exceptions are education organizations, which have the default set to moderators, and business organizations, which have the default set to all users. Fixes #34859. --- zerver/actions/create_realm.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/zerver/actions/create_realm.py b/zerver/actions/create_realm.py index 2c160a3c3f..a5d322030a 100644 --- a/zerver/actions/create_realm.py +++ b/zerver/actions/create_realm.py @@ -239,14 +239,21 @@ def do_create_realm( }, ) - realm_default_email_address_visibility = RealmUserDefault.EMAIL_ADDRESS_VISIBILITY_EVERYONE + # For the majority of organization types, the default email address visibility + # setting for new users should initially be admins only. + realm_default_email_address_visibility = RealmUserDefault.EMAIL_ADDRESS_VISIBILITY_ADMINS if realm.org_type in ( Realm.ORG_TYPES["education_nonprofit"]["id"], Realm.ORG_TYPES["education"]["id"], ): - # Email address of users should be initially visible to admins only. + # Email address of users should be initially visible to moderators and admins. realm_default_email_address_visibility = ( - RealmUserDefault.EMAIL_ADDRESS_VISIBILITY_ADMINS + RealmUserDefault.EMAIL_ADDRESS_VISIBILITY_MODERATORS + ) + if realm.org_type == Realm.ORG_TYPES["business"]["id"]: + # Email address of users can be visible to all users for business organizations. + realm_default_email_address_visibility = ( + RealmUserDefault.EMAIL_ADDRESS_VISIBILITY_EVERYONE ) RealmUserDefault.objects.create(