From 119f1da04afba9ac3b7f3cc1287597e981955b6b Mon Sep 17 00:00:00 2001 From: Mateusz Mandera Date: Sun, 7 Mar 2021 15:51:55 +0100 Subject: [PATCH] bots: Rename is_cross_realm_bot API field to is_system_bot. Cross realm bots will soon stop being a thing. This param is responsible for displaying "System Bot" in the user info popover - so this rename is the right way to handle the situation. We will likely want to rename the `cross_realm_bots` section as well, but that is a more involved API migration. --- static/js/popovers.js | 6 +++--- static/templates/user_info_popover_content.hbs | 2 +- templates/zerver/api/changelog.md | 6 ++++++ version.py | 2 +- zerver/lib/users.py | 2 +- zerver/openapi/zulip.yaml | 9 +++++++-- zerver/tests/test_event_system.py | 2 +- zerver/tests/test_home.py | 6 +++--- 8 files changed, 23 insertions(+), 12 deletions(-) diff --git a/static/js/popovers.js b/static/js/popovers.js index 41940a239c..904fd6da23 100644 --- a/static/js/popovers.js +++ b/static/js/popovers.js @@ -233,10 +233,10 @@ function render_user_info_popover( }; if (user.is_bot) { - const is_cross_realm_bot = user.is_cross_realm_bot; + const is_system_bot = user.is_system_bot; const bot_owner_id = user.bot_owner_id; - if (is_cross_realm_bot) { - args.is_cross_realm_bot = is_cross_realm_bot; + if (is_system_bot) { + args.is_system_bot = is_system_bot; } else if (bot_owner_id) { const bot_owner = people.get_by_user_id(bot_owner_id); args.bot_owner = bot_owner; diff --git a/static/templates/user_info_popover_content.hbs b/static/templates/user_info_popover_content.hbs index d9b8454222..34f58d1aee 100644 --- a/static/templates/user_info_popover_content.hbs +++ b/static/templates/user_info_popover_content.hbs @@ -40,7 +40,7 @@ {{else}} - {{#if is_cross_realm_bot}} + {{#if is_system_bot}}
  • {{#tr}}System bot{{/tr}}
  • {{else}}
  • {{#tr}}Bot{{/tr}}
  • diff --git a/templates/zerver/api/changelog.md b/templates/zerver/api/changelog.md index f9dbe5315a..775f599a7f 100644 --- a/templates/zerver/api/changelog.md +++ b/templates/zerver/api/changelog.md @@ -11,6 +11,12 @@ below features are supported. ## Changes in Zulip 5.0 +**Feature level 83** + +* * [`POST /register`](/api/register-queue): The `cross_realm_bots` + section of the response now uses the `is_system_bot` flag to + indicate whether the bot is a system bot. + **Feature level 82** * [`PATCH /settings`](/api/update-settings) now accepts a new diff --git a/version.py b/version.py index edff8dfff2..2d377f78bc 100644 --- a/version.py +++ b/version.py @@ -33,7 +33,7 @@ DESKTOP_WARNING_VERSION = "5.4.3" # Changes should be accompanied by documentation explaining what the # new level means in templates/zerver/api/changelog.md, as well as # "**Changes**" entries in the endpoint's documentation in `zulip.yaml`. -API_FEATURE_LEVEL = 82 +API_FEATURE_LEVEL = 83 # Bump the minor PROVISION_VERSION to indicate that folks should provision # only when going from an old version of the code to a newer version. Bump diff --git a/zerver/lib/users.py b/zerver/lib/users.py index 27d7579baa..bc6f8194cc 100644 --- a/zerver/lib/users.py +++ b/zerver/lib/users.py @@ -429,7 +429,7 @@ def format_user_row( if is_bot: result["bot_type"] = row["bot_type"] if row["email"] in settings.CROSS_REALM_BOT_EMAILS: - result["is_cross_realm_bot"] = True + result["is_system_bot"] = True # Note that bot_owner_id can be None with legacy data. result["bot_owner_id"] = row["bot_owner_id"] diff --git a/zerver/openapi/zulip.yaml b/zerver/openapi/zulip.yaml index 6e72287376..4c1f728660 100644 --- a/zerver/openapi/zulip.yaml +++ b/zerver/openapi/zulip.yaml @@ -9656,10 +9656,15 @@ paths: date_joined: {} delivery_email: {} profile_data: {} - is_cross_realm_bot: + is_system_bot: type: boolean description: | - Whether the user is a cross realm bot. + Whether the user is a system bot. System bots are special + bot user accounts that are managed by the system, rather than + the organization's administrators. + + **Changes**: This field was called `is_cross_realm_bot` + before Zulip 5.0 (feature level 83). example: { "last_event_id": -1, diff --git a/zerver/tests/test_event_system.py b/zerver/tests/test_event_system.py index 732400e106..e99a42def3 100644 --- a/zerver/tests/test_event_system.py +++ b/zerver/tests/test_event_system.py @@ -1120,7 +1120,7 @@ class TestGetRawUserDataSystemBotRealm(ZulipTestCase): for bot_email in settings.CROSS_REALM_BOT_EMAILS: bot_profile = get_system_bot(bot_email) self.assertTrue(bot_profile.id in result) - self.assertTrue(result[bot_profile.id]["is_cross_realm_bot"]) + self.assertTrue(result[bot_profile.id]["is_system_bot"]) class TestUserPresenceUpdatesDisabled(ZulipTestCase): diff --git a/zerver/tests/test_home.py b/zerver/tests/test_home.py index c4e89dfec2..5bb9ae20d3 100644 --- a/zerver/tests/test_home.py +++ b/zerver/tests/test_home.py @@ -628,7 +628,7 @@ class HomeTest(ZulipTestCase): is_owner=False, is_billing_admin=False, role=email_gateway_bot.role, - is_cross_realm_bot=True, + is_system_bot=True, is_guest=False, ), dict( @@ -644,7 +644,7 @@ class HomeTest(ZulipTestCase): is_owner=False, is_billing_admin=False, role=notification_bot.role, - is_cross_realm_bot=True, + is_system_bot=True, is_guest=False, ), dict( @@ -660,7 +660,7 @@ class HomeTest(ZulipTestCase): is_owner=False, is_billing_admin=False, role=welcome_bot.role, - is_cross_realm_bot=True, + is_system_bot=True, is_guest=False, ), ],