mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-03 21:43:21 +00:00 
			
		
		
		
	bots: Remove feedback cross realm bot.
This completes the remaining pieces of removing this missed in
d70e799466 (mostly in tests).
Backported to 2.1.x branch.
			
			
This commit is contained in:
		
				
					committed by
					
						
						Mateusz Mandera
					
				
			
			
				
	
			
			
			
						parent
						
							cae803e8a9
						
					
				
				
					commit
					cee6227f53
				
			@@ -6,7 +6,7 @@ There are three disjoint sets of users you care about
 | 
				
			|||||||
for typical Zulip realms:
 | 
					for typical Zulip realms:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
- active users in your realm
 | 
					- active users in your realm
 | 
				
			||||||
- cross-realm users like feedback@zulip.com
 | 
					- cross-realm users like welcome-bot@zulip.com
 | 
				
			||||||
- deactivated users in your realm
 | 
					- deactivated users in your realm
 | 
				
			||||||
 | 
					
 | 
				
			||||||
You can also think in terms of these user populations:
 | 
					You can also think in terms of these user populations:
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -143,7 +143,7 @@ casper.then(function () {
 | 
				
			|||||||
casper.then(function () {
 | 
					casper.then(function () {
 | 
				
			||||||
    casper.click('*[title="Narrow to your private messages with Cordelia Lear"]');
 | 
					    casper.click('*[title="Narrow to your private messages with Cordelia Lear"]');
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
casper.waitUntilVisible('li[data-user-ids-string="9"].expanded_private_message.active-sub-filter', function () {
 | 
					casper.waitUntilVisible('li[data-user-ids-string="8"].expanded_private_message.active-sub-filter', function () {
 | 
				
			||||||
    casper.page.sendEvent('keypress', 'c');
 | 
					    casper.page.sendEvent('keypress', 'c');
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -263,15 +263,15 @@ run_test('validate', () => {
 | 
				
			|||||||
});
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
run_test('get_invalid_recipient_emails', () => {
 | 
					run_test('get_invalid_recipient_emails', () => {
 | 
				
			||||||
    const feedback_bot = {
 | 
					    const welcome_bot = {
 | 
				
			||||||
        email: 'feedback@example.com',
 | 
					        email: 'welcome-bot@example.com',
 | 
				
			||||||
        user_id: 124,
 | 
					        user_id: 124,
 | 
				
			||||||
        full_name: 'Feedback Bot',
 | 
					        full_name: 'Welcome Bot',
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
    page_params.cross_realm_bots = [feedback_bot];
 | 
					    page_params.cross_realm_bots = [welcome_bot];
 | 
				
			||||||
    page_params.user_id = 30;
 | 
					    page_params.user_id = 30;
 | 
				
			||||||
    people.initialize();
 | 
					    people.initialize();
 | 
				
			||||||
    compose_state.private_message_recipient('feedback@example.com');
 | 
					    compose_state.private_message_recipient('welcome-bot@example.com');
 | 
				
			||||||
    assert.deepEqual(compose.get_invalid_recipient_emails(), []);
 | 
					    assert.deepEqual(compose.get_invalid_recipient_emails(), []);
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -30,8 +30,7 @@
 | 
				
			|||||||
                </ol>
 | 
					                </ol>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                <h2>You're done!</h2>
 | 
					                <h2>You're done!</h2>
 | 
				
			||||||
                <p>If you have any questions, please contact us using the "Send feedback" button in Zulip or e-mail us at
 | 
					                <p>If you have any questions, please e-mail us at <a href="mailto:{{ support_email }}">{{ support_email }}</a></p>
 | 
				
			||||||
                <a href="mailto:{{ support_email }}">{{ support_email }}</a></p>
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
                <h2>If you want to automatically transfer your existing Zephyr subscriptions</h2>
 | 
					                <h2>If you want to automatically transfer your existing Zephyr subscriptions</h2>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -978,13 +978,13 @@ def remove_alert_words(client):
 | 
				
			|||||||
@openapi_test_function("/user_groups/create:post")
 | 
					@openapi_test_function("/user_groups/create:post")
 | 
				
			||||||
def create_user_group(client):
 | 
					def create_user_group(client):
 | 
				
			||||||
    # type: (Client) -> None
 | 
					    # type: (Client) -> None
 | 
				
			||||||
    ensure_users([7, 8, 9, 10], ['aaron', 'zoe', 'cordelia', 'hamlet'])
 | 
					    ensure_users([6, 7, 8, 9], ['aaron', 'zoe', 'cordelia', 'hamlet'])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # {code_example|start}
 | 
					    # {code_example|start}
 | 
				
			||||||
    request = {
 | 
					    request = {
 | 
				
			||||||
        'name': 'marketing',
 | 
					        'name': 'marketing',
 | 
				
			||||||
        'description': 'The marketing team.',
 | 
					        'description': 'The marketing team.',
 | 
				
			||||||
        'members': [7, 8, 9, 10],
 | 
					        'members': [6, 7, 8, 9],
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    result = client.create_user_group(request)
 | 
					    result = client.create_user_group(request)
 | 
				
			||||||
@@ -1020,12 +1020,12 @@ def remove_user_group(client, group_id):
 | 
				
			|||||||
@openapi_test_function("/user_groups/{group_id}/members:post")
 | 
					@openapi_test_function("/user_groups/{group_id}/members:post")
 | 
				
			||||||
def update_user_group_members(client, group_id):
 | 
					def update_user_group_members(client, group_id):
 | 
				
			||||||
    # type: (Client, int) -> None
 | 
					    # type: (Client, int) -> None
 | 
				
			||||||
    ensure_users([9, 10, 11], ['cordelia', 'hamlet', 'iago'])
 | 
					    ensure_users([8, 9, 10], ['cordelia', 'hamlet', 'iago'])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    request = {
 | 
					    request = {
 | 
				
			||||||
        'group_id': group_id,
 | 
					        'group_id': group_id,
 | 
				
			||||||
        'delete': [9, 10],
 | 
					        'delete': [8, 9],
 | 
				
			||||||
        'add': [11]
 | 
					        'add': [10]
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    result = client.update_user_group_members(request)
 | 
					    result = client.update_user_group_members(request)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -566,7 +566,7 @@ class HomeTest(ZulipTestCase):
 | 
				
			|||||||
        self.assertNotIn('defunct-1@zulip.com', active_emails)
 | 
					        self.assertNotIn('defunct-1@zulip.com', active_emails)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        cross_bots = page_params['cross_realm_bots']
 | 
					        cross_bots = page_params['cross_realm_bots']
 | 
				
			||||||
        self.assertEqual(len(cross_bots), 4)
 | 
					        self.assertEqual(len(cross_bots), 3)
 | 
				
			||||||
        cross_bots.sort(key=lambda d: d['email'])
 | 
					        cross_bots.sort(key=lambda d: d['email'])
 | 
				
			||||||
        for cross_bot in cross_bots:
 | 
					        for cross_bot in cross_bots:
 | 
				
			||||||
            # These are either nondeterministic or boring
 | 
					            # These are either nondeterministic or boring
 | 
				
			||||||
@@ -586,13 +586,6 @@ class HomeTest(ZulipTestCase):
 | 
				
			|||||||
                full_name='Email Gateway',
 | 
					                full_name='Email Gateway',
 | 
				
			||||||
                is_bot=True
 | 
					                is_bot=True
 | 
				
			||||||
            ),
 | 
					            ),
 | 
				
			||||||
            dict(
 | 
					 | 
				
			||||||
                user_id=get_system_bot('feedback@zulip.com').id,
 | 
					 | 
				
			||||||
                is_admin=False,
 | 
					 | 
				
			||||||
                email='feedback@zulip.com',
 | 
					 | 
				
			||||||
                full_name='Zulip Feedback Bot',
 | 
					 | 
				
			||||||
                is_bot=True
 | 
					 | 
				
			||||||
            ),
 | 
					 | 
				
			||||||
            dict(
 | 
					            dict(
 | 
				
			||||||
                user_id=notification_bot.id,
 | 
					                user_id=notification_bot.id,
 | 
				
			||||||
                is_admin=False,
 | 
					                is_admin=False,
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -349,7 +349,7 @@ class TestCrossRealmPMs(ZulipTestCase):
 | 
				
			|||||||
        return get_user(email, get_realm(subdomain))
 | 
					        return get_user(email, get_realm(subdomain))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @slow("Sends a large number of messages")
 | 
					    @slow("Sends a large number of messages")
 | 
				
			||||||
    @override_settings(CROSS_REALM_BOT_EMAILS=['feedback@zulip.com',
 | 
					    @override_settings(CROSS_REALM_BOT_EMAILS=['notification-bot@zulip.com',
 | 
				
			||||||
                                               'welcome-bot@zulip.com',
 | 
					                                               'welcome-bot@zulip.com',
 | 
				
			||||||
                                               'support@3.example.com'])
 | 
					                                               'support@3.example.com'])
 | 
				
			||||||
    def test_realm_scenarios(self) -> None:
 | 
					    def test_realm_scenarios(self) -> None:
 | 
				
			||||||
@@ -370,15 +370,15 @@ class TestCrossRealmPMs(ZulipTestCase):
 | 
				
			|||||||
        user1a_email = 'user1a@1.example.com'
 | 
					        user1a_email = 'user1a@1.example.com'
 | 
				
			||||||
        user2_email = 'user2@2.example.com'
 | 
					        user2_email = 'user2@2.example.com'
 | 
				
			||||||
        user3_email = 'user3@3.example.com'
 | 
					        user3_email = 'user3@3.example.com'
 | 
				
			||||||
        feedback_email = 'feedback@zulip.com'
 | 
					        notification_bot_email = 'notification-bot@zulip.com'
 | 
				
			||||||
        support_email = 'support@3.example.com'  # note: not zulip.com
 | 
					        support_email = 'support@3.example.com'  # note: not zulip.com
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        user1 = self.create_user(user1_email)
 | 
					        user1 = self.create_user(user1_email)
 | 
				
			||||||
        user1a = self.create_user(user1a_email)
 | 
					        user1a = self.create_user(user1a_email)
 | 
				
			||||||
        user2 = self.create_user(user2_email)
 | 
					        user2 = self.create_user(user2_email)
 | 
				
			||||||
        self.create_user(user3_email)
 | 
					        self.create_user(user3_email)
 | 
				
			||||||
        feedback_bot = get_system_bot(feedback_email)
 | 
					        notification_bot = get_system_bot(notification_bot_email)
 | 
				
			||||||
        with self.settings(CROSS_REALM_BOT_EMAILS=['feedback@zulip.com', 'welcome-bot@zulip.com']):
 | 
					        with self.settings(CROSS_REALM_BOT_EMAILS=['notification-bot@zulip.com', 'welcome-bot@zulip.com']):
 | 
				
			||||||
            # HACK: We should probably be creating this "bot" user another
 | 
					            # HACK: We should probably be creating this "bot" user another
 | 
				
			||||||
            # way, but since you can't register a user with a
 | 
					            # way, but since you can't register a user with a
 | 
				
			||||||
            # cross-realm email, we need to hide this for now.
 | 
					            # cross-realm email, we need to hide this for now.
 | 
				
			||||||
@@ -396,15 +396,15 @@ class TestCrossRealmPMs(ZulipTestCase):
 | 
				
			|||||||
        # (They need lower level APIs to do this.)
 | 
					        # (They need lower level APIs to do this.)
 | 
				
			||||||
        internal_send_private_message(
 | 
					        internal_send_private_message(
 | 
				
			||||||
            realm=r2,
 | 
					            realm=r2,
 | 
				
			||||||
            sender=get_system_bot(feedback_email),
 | 
					            sender=get_system_bot(notification_bot_email),
 | 
				
			||||||
            recipient_user=get_user(user2_email, r2),
 | 
					            recipient_user=get_user(user2_email, r2),
 | 
				
			||||||
            content='bla',
 | 
					            content='bla',
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
        assert_message_received(user2, feedback_bot)
 | 
					        assert_message_received(user2, notification_bot)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # All users can PM cross-realm bots in the zulip.com realm
 | 
					        # All users can PM cross-realm bots in the zulip.com realm
 | 
				
			||||||
        self.send_personal_message(user1_email, feedback_email, sender_realm="1.example.com")
 | 
					        self.send_personal_message(user1_email, notification_bot_email, sender_realm="1.example.com")
 | 
				
			||||||
        assert_message_received(feedback_bot, user1)
 | 
					        assert_message_received(notification_bot, user1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # Users can PM cross-realm bots on non-zulip realms.
 | 
					        # Users can PM cross-realm bots on non-zulip realms.
 | 
				
			||||||
        # (The support bot represents some theoretical bot that we may
 | 
					        # (The support bot represents some theoretical bot that we may
 | 
				
			||||||
@@ -417,9 +417,9 @@ class TestCrossRealmPMs(ZulipTestCase):
 | 
				
			|||||||
        # already individually send PMs to cross-realm bots, we shouldn't
 | 
					        # already individually send PMs to cross-realm bots, we shouldn't
 | 
				
			||||||
        # prevent them from sending multiple bots at once.  We may revisit
 | 
					        # prevent them from sending multiple bots at once.  We may revisit
 | 
				
			||||||
        # this if it's a nuisance for huddles.)
 | 
					        # this if it's a nuisance for huddles.)
 | 
				
			||||||
        self.send_huddle_message(user1_email, [feedback_email, support_email],
 | 
					        self.send_huddle_message(user1_email, [notification_bot_email, support_email],
 | 
				
			||||||
                                 sender_realm="1.example.com")
 | 
					                                 sender_realm="1.example.com")
 | 
				
			||||||
        assert_message_received(feedback_bot, user1)
 | 
					        assert_message_received(notification_bot, user1)
 | 
				
			||||||
        assert_message_received(support_bot, user1)
 | 
					        assert_message_received(support_bot, user1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # Prevent old loophole where I could send PMs to other users as long
 | 
					        # Prevent old loophole where I could send PMs to other users as long
 | 
				
			||||||
@@ -431,11 +431,11 @@ class TestCrossRealmPMs(ZulipTestCase):
 | 
				
			|||||||
        # Users on three different realms can't PM each other,
 | 
					        # Users on three different realms can't PM each other,
 | 
				
			||||||
        # even if one of the users is a cross-realm bot.
 | 
					        # even if one of the users is a cross-realm bot.
 | 
				
			||||||
        with assert_invalid_email():
 | 
					        with assert_invalid_email():
 | 
				
			||||||
            self.send_huddle_message(user1_email, [user2_email, feedback_email],
 | 
					            self.send_huddle_message(user1_email, [user2_email, notification_bot_email],
 | 
				
			||||||
                                     sender_realm="1.example.com")
 | 
					                                     sender_realm="1.example.com")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        with assert_invalid_email():
 | 
					        with assert_invalid_email():
 | 
				
			||||||
            self.send_huddle_message(feedback_email, [user1_email, user2_email],
 | 
					            self.send_huddle_message(notification_bot_email, [user1_email, user2_email],
 | 
				
			||||||
                                     sender_realm=settings.SYSTEM_BOT_REALM)
 | 
					                                     sender_realm=settings.SYSTEM_BOT_REALM)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # Users on the different realms cannot PM each other
 | 
					        # Users on the different realms cannot PM each other
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -576,9 +576,6 @@ def create_internal_realm() -> None:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    internal_realm_bots = [(bot['name'], bot['email_template'] % (settings.INTERNAL_BOT_DOMAIN,))
 | 
					    internal_realm_bots = [(bot['name'], bot['email_template'] % (settings.INTERNAL_BOT_DOMAIN,))
 | 
				
			||||||
                           for bot in settings.INTERNAL_BOTS]
 | 
					                           for bot in settings.INTERNAL_BOTS]
 | 
				
			||||||
    internal_realm_bots += [
 | 
					 | 
				
			||||||
        ("Zulip Feedback Bot", "feedback@zulip.com"),
 | 
					 | 
				
			||||||
    ]
 | 
					 | 
				
			||||||
    create_users(internal_realm, internal_realm_bots, bot_type=UserProfile.DEFAULT_BOT)
 | 
					    create_users(internal_realm, internal_realm_bots, bot_type=UserProfile.DEFAULT_BOT)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Initialize the email gateway bot as an API Super User
 | 
					    # Initialize the email gateway bot as an API Super User
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1055,7 +1055,6 @@ if PRODUCTION:
 | 
				
			|||||||
PROFILE_ALL_REQUESTS = False
 | 
					PROFILE_ALL_REQUESTS = False
 | 
				
			||||||
 | 
					
 | 
				
			||||||
CROSS_REALM_BOT_EMAILS = {
 | 
					CROSS_REALM_BOT_EMAILS = {
 | 
				
			||||||
    'feedback@zulip.com',
 | 
					 | 
				
			||||||
    'notification-bot@zulip.com',
 | 
					    'notification-bot@zulip.com',
 | 
				
			||||||
    'welcome-bot@zulip.com',
 | 
					    'welcome-bot@zulip.com',
 | 
				
			||||||
    'emailgateway@zulip.com',
 | 
					    'emailgateway@zulip.com',
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user