From 5efe78205dd96cdd46eb26ecb57d4b4d2ba673b1 Mon Sep 17 00:00:00 2001 From: Junyao Chen Date: Mon, 21 Aug 2023 21:53:15 -0400 Subject: [PATCH] bot_data: Fix `owner_id` field to allow null value. According to zulip `/register` API doc, `realm_bots[].owner_id` should be nullable. Fixes commit 71401493738e28ea90203a667b307816a5e4feed. --- web/src/bot_data.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/web/src/bot_data.ts b/web/src/bot_data.ts index 3fceb5a8bf..c457577a7d 100644 --- a/web/src/bot_data.ts +++ b/web/src/bot_data.ts @@ -26,7 +26,7 @@ const basic_bot_schema = z.object({ email: z.string(), full_name: z.string(), is_active: z.boolean(), - owner_id: z.number(), + owner_id: z.number().nullable(), user_id: z.number(), }); @@ -90,7 +90,7 @@ export function update(bot_id: number, bot_update: ServerUpdateBotData): void { export function get_all_bots_for_current_user(): Bot[] { const ret = []; for (const bot of bots.values()) { - if (people.is_my_user_id(bot.owner_id)) { + if (bot.owner_id !== null && people.is_my_user_id(bot.owner_id)) { ret.push(bot); } } @@ -100,7 +100,7 @@ export function get_all_bots_for_current_user(): Bot[] { export function get_editable(): Bot[] { const ret = []; for (const bot of bots.values()) { - if (bot.is_active && people.is_my_user_id(bot.owner_id)) { + if (bot.is_active && bot.owner_id !== null && people.is_my_user_id(bot.owner_id)) { ret.push(bot); } }