diff --git a/web/src/people.ts b/web/src/people.ts index de6428f184..b790961d85 100644 --- a/web/src/people.ts +++ b/web/src/people.ts @@ -121,8 +121,8 @@ export function get_by_user_id(user_id: number): User { } // This is type unsafe version of get_by_user_id for the callers that expects undefined values. -export function maybe_get_user_by_id(user_id: number): User | undefined { - if (!people_by_user_id_dict.has(user_id)) { +export function maybe_get_user_by_id(user_id: number, ignore_missing = false): User | undefined { + if (!people_by_user_id_dict.has(user_id) && !ignore_missing) { blueslip.error("Unknown user_id in maybe_get_user_by_id", {user_id}); return undefined; } diff --git a/web/src/presence.js b/web/src/presence.js index 6b240e69a2..c5dc7a6e88 100644 --- a/web/src/presence.js +++ b/web/src/presence.js @@ -175,7 +175,7 @@ export function set_info(presences, server_timestamp) { // reload_state.is_in_progress, because races where presence // returns data on users not yet received via the server_events // system are common in both situations. - const person = people.maybe_get_user_by_id(user_id); + const person = people.maybe_get_user_by_id(user_id, true); if (person === undefined) { if (!(watchdog.suspects_user_is_offline() || reload_state.is_in_progress())) { // If we're online, and we get a user who we don't diff --git a/web/src/rendered_markdown.js b/web/src/rendered_markdown.js index 764ebe3df4..ae3f55b90b 100644 --- a/web/src/rendered_markdown.js +++ b/web/src/rendered_markdown.js @@ -107,7 +107,7 @@ export const update_elements = ($content) => { // mention text to show the user's current name, // assuming that you're not searching for text // inside the highlight. - const person = people.maybe_get_user_by_id(user_id); + const person = people.maybe_get_user_by_id(user_id, true); if (person !== undefined) { // Note that person might be undefined in some // unpleasant corner cases involving data import. diff --git a/web/tests/presence.test.js b/web/tests/presence.test.js index 89745a0e18..8fb2c5362f 100644 --- a/web/tests/presence.test.js +++ b/web/tests/presence.test.js @@ -95,7 +95,6 @@ test("unknown user", ({override}) => { const presences = {}; presences[unknown_user_id.toString()] = "does-not-matter"; - blueslip.expect("error", "Unknown user_id in maybe_get_user_by_id", 3); blueslip.expect("error", "Unknown user ID in presence data"); presence.set_info(presences, now);