diff --git a/zerver/lib/actions.py b/zerver/lib/actions.py index b23d5de133..4fc8fd9409 100644 --- a/zerver/lib/actions.py +++ b/zerver/lib/actions.py @@ -4092,16 +4092,7 @@ def email_not_system_bot(email: Text) -> None: raise ValidationError('%s is an email address reserved for system bots' % (email,)) def validate_email_for_realm(target_realm: Realm, email: Text) -> None: - try: - # Registering with a system bot's email is not allowed... - email_not_system_bot(email) - except ValidationError: - # ... unless this is the first user with that email. This - # should be impossible in production, because these users are - # created by initialize_voyager_db, but it happens in a test's - # setup. (This would be a good wrinkle to clean up.) - if UserProfile.objects.filter(email__iexact=email).exists(): - raise + email_not_system_bot(email) try: existing_user_profile = get_user(email, target_realm) diff --git a/zerver/tests/test_messages.py b/zerver/tests/test_messages.py index 8fff47f9b1..bfb4cf7814 100644 --- a/zerver/tests/test_messages.py +++ b/zerver/tests/test_messages.py @@ -266,7 +266,11 @@ class TestCrossRealmPMs(ZulipTestCase): user2 = self.create_user(user2_email) self.create_user(user3_email) feedback_bot = get_system_bot(feedback_email) - support_bot = self.create_user(support_email) + with self.settings(CROSS_REALM_BOT_EMAILS=['feedback@zulip.com', 'welcome-bot@zulip.com']): + # HACK: We should probably be creating this "bot" user another + # way, but since you can't register a user with a + # cross-realm email, we need to hide this for now. + support_bot = self.create_user(support_email) # Users can PM themselves self.send_personal_message(user1_email, user1_email, sender_realm="1.example.com")