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.
This commit is contained in:
Mateusz Mandera 2021-03-07 15:51:55 +01:00 committed by Tim Abbott
parent 1652e5c031
commit 119f1da04a
8 changed files with 23 additions and 12 deletions

View File

@ -233,10 +233,10 @@ function render_user_info_popover(
}; };
if (user.is_bot) { 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; const bot_owner_id = user.bot_owner_id;
if (is_cross_realm_bot) { if (is_system_bot) {
args.is_cross_realm_bot = is_cross_realm_bot; args.is_system_bot = is_system_bot;
} else if (bot_owner_id) { } else if (bot_owner_id) {
const bot_owner = people.get_by_user_id(bot_owner_id); const bot_owner = people.get_by_user_id(bot_owner_id);
args.bot_owner = bot_owner; args.bot_owner = bot_owner;

View File

@ -40,7 +40,7 @@
</span> </span>
</li> </li>
{{else}} {{else}}
{{#if is_cross_realm_bot}} {{#if is_system_bot}}
<li>{{#tr}}System bot{{/tr}}</li> <li>{{#tr}}System bot{{/tr}}</li>
{{else}} {{else}}
<li>{{#tr}}Bot{{/tr}}</li> <li>{{#tr}}Bot{{/tr}}</li>

View File

@ -11,6 +11,12 @@ below features are supported.
## Changes in Zulip 5.0 ## 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** **Feature level 82**
* [`PATCH /settings`](/api/update-settings) now accepts a new * [`PATCH /settings`](/api/update-settings) now accepts a new

View File

@ -33,7 +33,7 @@ DESKTOP_WARNING_VERSION = "5.4.3"
# Changes should be accompanied by documentation explaining what the # Changes should be accompanied by documentation explaining what the
# new level means in templates/zerver/api/changelog.md, as well as # new level means in templates/zerver/api/changelog.md, as well as
# "**Changes**" entries in the endpoint's documentation in `zulip.yaml`. # "**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 # 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 # only when going from an old version of the code to a newer version. Bump

View File

@ -429,7 +429,7 @@ def format_user_row(
if is_bot: if is_bot:
result["bot_type"] = row["bot_type"] result["bot_type"] = row["bot_type"]
if row["email"] in settings.CROSS_REALM_BOT_EMAILS: 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. # Note that bot_owner_id can be None with legacy data.
result["bot_owner_id"] = row["bot_owner_id"] result["bot_owner_id"] = row["bot_owner_id"]

View File

@ -9656,10 +9656,15 @@ paths:
date_joined: {} date_joined: {}
delivery_email: {} delivery_email: {}
profile_data: {} profile_data: {}
is_cross_realm_bot: is_system_bot:
type: boolean type: boolean
description: | 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: example:
{ {
"last_event_id": -1, "last_event_id": -1,

View File

@ -1120,7 +1120,7 @@ class TestGetRawUserDataSystemBotRealm(ZulipTestCase):
for bot_email in settings.CROSS_REALM_BOT_EMAILS: for bot_email in settings.CROSS_REALM_BOT_EMAILS:
bot_profile = get_system_bot(bot_email) bot_profile = get_system_bot(bot_email)
self.assertTrue(bot_profile.id in result) 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): class TestUserPresenceUpdatesDisabled(ZulipTestCase):

View File

@ -628,7 +628,7 @@ class HomeTest(ZulipTestCase):
is_owner=False, is_owner=False,
is_billing_admin=False, is_billing_admin=False,
role=email_gateway_bot.role, role=email_gateway_bot.role,
is_cross_realm_bot=True, is_system_bot=True,
is_guest=False, is_guest=False,
), ),
dict( dict(
@ -644,7 +644,7 @@ class HomeTest(ZulipTestCase):
is_owner=False, is_owner=False,
is_billing_admin=False, is_billing_admin=False,
role=notification_bot.role, role=notification_bot.role,
is_cross_realm_bot=True, is_system_bot=True,
is_guest=False, is_guest=False,
), ),
dict( dict(
@ -660,7 +660,7 @@ class HomeTest(ZulipTestCase):
is_owner=False, is_owner=False,
is_billing_admin=False, is_billing_admin=False,
role=welcome_bot.role, role=welcome_bot.role,
is_cross_realm_bot=True, is_system_bot=True,
is_guest=False, is_guest=False,
), ),
], ],