diff --git a/corporate/lib/registration.py b/corporate/lib/registration.py index 3bfc9c6a78..336f006523 100644 --- a/corporate/lib/registration.py +++ b/corporate/lib/registration.py @@ -5,7 +5,7 @@ from django.utils.translation import gettext as _ from corporate.lib.stripe import LicenseLimitError, get_latest_seat_count, get_seat_count from corporate.models import get_current_plan_by_realm -from zerver.actions.create_user import send_message_to_signup_notification_stream +from zerver.actions.create_user import send_group_direct_message_to_admins from zerver.lib.exceptions import InvitationError from zerver.models import Realm, UserProfile from zerver.models.users import get_system_bot @@ -51,7 +51,7 @@ def generate_licenses_low_warning_message_if_required(realm: Realm) -> Optional[ }[licenses_remaining].format(**format_kwargs) -def send_user_unable_to_signup_message_to_signup_notification_stream( +def send_user_unable_to_signup_group_direct_message_to_admins( realm: Realm, user_email: str ) -> None: message = _( @@ -64,7 +64,7 @@ def send_user_unable_to_signup_message_to_signup_notification_stream( deactivate_user_help_page_link="/help/deactivate-or-reactivate-a-user", ) - send_message_to_signup_notification_stream( + send_group_direct_message_to_admins( get_system_bot(settings.NOTIFICATION_BOT, realm.id), realm, message ) @@ -93,7 +93,7 @@ def check_spare_licenses_available_for_registering_new_user( else: check_spare_licenses_available_for_adding_new_users(realm, extra_non_guests_count=1) except LicenseLimitError: - send_user_unable_to_signup_message_to_signup_notification_stream(realm, user_email_to_add) + send_user_unable_to_signup_group_direct_message_to_admins(realm, user_email_to_add) raise diff --git a/zerver/tests/test_signup.py b/zerver/tests/test_signup.py index 793a67b93a..ff683d874a 100644 --- a/zerver/tests/test_signup.py +++ b/zerver/tests/test_signup.py @@ -78,6 +78,7 @@ from zerver.models import ( UserProfile, ) from zerver.models.realms import get_realm +from zerver.models.recipients import get_huddle_user_ids from zerver.models.streams import get_stream from zerver.models.users import get_system_bot, get_user, get_user_by_delivery_email from zerver.views.auth import redirect_and_log_into_subdomain, start_two_factor_auth @@ -2868,9 +2869,9 @@ class UserSignUpTest(ZulipTestCase): def test_signup_to_realm_on_manual_license_plan(self) -> None: realm = get_realm("zulip") - denmark_stream = get_stream("Denmark", realm) - realm.signup_announcements_stream = denmark_stream - realm.save(update_fields=["signup_announcements_stream"]) + admin_user_ids = set(realm.get_human_admin_users().values_list("id", flat=True)) + notification_bot = get_system_bot(settings.NOTIFICATION_BOT, realm.id) + expected_group_direct_message_user_ids = admin_user_ids | {notification_bot.id} _, ledger = self.subscribe_realm_to_monthly_plan_on_manual_license_management(realm, 5, 5) @@ -2886,7 +2887,10 @@ class UserSignUpTest(ZulipTestCase): f"A new member ({self.nonreg_email('test')}) was unable to join your organization because all Zulip", last_message.content, ) - self.assertEqual(last_message.recipient.type_id, denmark_stream.id) + self.assertEqual( + set(get_huddle_user_ids(last_message.recipient)), + expected_group_direct_message_user_ids, + ) ledger.licenses_at_next_renewal = 50 ledger.save(update_fields=["licenses_at_next_renewal"])