diff --git a/web/src/people.ts b/web/src/people.ts index 7c56edfe35..ea987df501 100644 --- a/web/src/people.ts +++ b/web/src/people.ts @@ -14,12 +14,7 @@ import {page_params} from "./page_params"; import * as reload_state from "./reload_state"; import * as settings_config from "./settings_config"; import * as settings_data from "./settings_data"; -import type { - StateData, - cross_realm_bot_schema, - profile_datum_schema, - user_schema, -} from "./state_data"; +import type {StateData, profile_datum_schema, user_schema} from "./state_data"; import {current_user, realm} from "./state_data"; import * as timerender from "./timerender"; import {is_user_in_group} from "./user_groups"; @@ -43,20 +38,18 @@ export type PseudoMentionUser = { idx: number; }; -export type CrossRealmBot = z.infer; - let people_dict: FoldDict; let people_by_name_dict: FoldDict; let people_by_user_id_dict: Map; let active_user_dict: Map; let non_active_user_dict: Map; -let cross_realm_dict: Map; +let cross_realm_dict: Map; let pm_recipient_count_dict: Map; let duplicate_full_name_data: FoldDict>; let my_user_id: number; export let INACCESSIBLE_USER_NAME: string; -export let WELCOME_BOT: CrossRealmBot; +export let WELCOME_BOT: User; // We have an init() function so that our automated tests // can easily clear data. @@ -1403,7 +1396,7 @@ export const is_person_active = (user_id: number): boolean => { return active_user_dict.has(user_id); }; -export function add_cross_realm_user(person: CrossRealmBot): void { +export function add_cross_realm_user(person: User): void { if (!people_dict.has(person.email)) { _add_user(person); } diff --git a/web/src/state_data.ts b/web/src/state_data.ts index ccb95a4262..52d8e3f6d8 100644 --- a/web/src/state_data.ts +++ b/web/src/state_data.ts @@ -96,6 +96,7 @@ export const user_schema = z is_missing_server_data: z.optional(z.boolean()), // used for inaccessible user objects. is_inaccessible_user: z.optional(z.boolean()), + is_system_bot: z.optional(z.literal(true)), }) .and( z.discriminatedUnion("is_bot", [ @@ -111,12 +112,6 @@ export const user_schema = z ]), ); -export const cross_realm_bot_schema = user_schema.and( - z.object({ - is_system_bot: z.boolean(), - }), -); - export const server_emoji_schema = z.object({ id: z.string(), author_id: z.number(), @@ -410,7 +405,7 @@ export const state_data_schema = z .object({ realm_users: z.array(user_schema), realm_non_active_users: z.array(user_schema), - cross_realm_bots: z.array(cross_realm_bot_schema), + cross_realm_bots: z.array(user_schema), }) .transform((people) => ({people})), )