Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
users: Handle UI for bots when bot owner is inaccessible.
Sahil Batra99f4f914e2c7
diff --git a/web/src/people.ts b/web/src/people.tsindex 2f95eaa8358..4101a3d43e7 100644--- a/web/src/people.ts+++ b/web/src/people.ts@@ -185,7 +185,7 @@ export function get_bot_owner_user(user: User & {is_bot: true}): User | undefinereturn undefined;}- return get_by_user_id(owner_id);+ return get_user_by_id_assert_valid(owner_id);}export function can_admin_user(user: User): boolean {diff --git a/web/src/user_card_popover.js b/web/src/user_card_popover.jsindex 6848129a9ba..353976728cf 100644--- a/web/src/user_card_popover.js+++ b/web/src/user_card_popover.js@@ -298,7 +298,7 @@ function get_user_card_popover_data(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);+ const bot_owner = people.get_bot_owner_user(bot_owner_id);args.bot_owner = bot_owner;}}diff --git a/web/src/user_profile.js b/web/src/user_profile.jsindex d9ba7545eac..6eaa3c028cb 100644--- a/web/src/user_profile.js+++ b/web/src/user_profile.js@@ -393,7 +393,7 @@ export function show_user_profile(user, default_tab_key = "profile-tab") {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);+ const bot_owner = people.get_bot_owner_user(bot_owner_id);args.bot_owner = bot_owner;}args.bot_type = settings_data.bot_type_id_to_string(user.bot_type);diff --git a/web/tests/people.test.js b/web/tests/people.test.jsindex 061b9ff688d..5dc17bf05a6 100644--- a/web/tests/people.test.js+++ b/web/tests/people.test.js@@ -141,6 +141,15 @@ const moderator = {role: 300,};+const bot_with_inaccesible_owner = {+ email: "[email protected]",+ user_id: 37,+ full_name: "Inaccessible owner bot",+ is_bot: true,+ bot_owner_id: 38,+ role: 300,+};+const steven = {email: "[email protected]",delivery_email: "[email protected]",@@ -267,7 +276,7 @@ function get_all_persons() {return people.filter_all_persons(() => true);}-test_people("basics", () => {+test_people("basics", ({override}) => {const persons = get_all_persons();assert.deepEqual(people.get_realm_users(), [me]);@@ -340,6 +349,12 @@ test_people("basics", () => {assert.equal(people.get_active_human_count(), 1);assert.equal(people.get_by_email(welcome_bot.email).full_name, "Welcome Bot");+ override(settings_data, "user_can_access_all_other_users", () => false);+ assert.equal(+ people.get_bot_owner_user(bot_with_inaccesible_owner).full_name,+ "translated: Unknown user",+ );+// get_realm_users() will include our active bot,// but will exclude isaac (who is deactivated)assert.deepEqual(