mirror of https://github.com/zulip/zulip.git
presence: Do not raise blueslip error for presence data of unknown user.
We have already fixed the actual bugs that were resulting in client receiving presence data for unknown user, so we can remove the blueslip logging and just skip the unknown users.
This commit is contained in:
parent
d5d1540118
commit
7da68259a6
|
@ -1,9 +1,6 @@
|
|||
import * as blueslip from "./blueslip";
|
||||
import {page_params} from "./page_params";
|
||||
import * as people from "./people";
|
||||
import * as reload_state from "./reload_state";
|
||||
import {user_settings} from "./user_settings";
|
||||
import * as watchdog from "./watchdog";
|
||||
|
||||
export type RawPresence = {
|
||||
server_timestamp: number;
|
||||
|
@ -206,11 +203,15 @@ export function set_info(
|
|||
// system are common in both situations.
|
||||
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
|
||||
// know about in the presence data, throw an error.
|
||||
blueslip.error("Unknown user ID in presence data", {user_id});
|
||||
}
|
||||
// There are a number of situations where it is expected
|
||||
// that we get presence data for a user ID that we do
|
||||
// not have in our user database, including when we're
|
||||
// offline/reloading (watchdog.suspects_user_is_offline()
|
||||
// || reload_state.is_in_progress()), when
|
||||
// CAN_ACCESS_ALL_USERS_GROUP_LIMITS_PRESENCE is disabled,
|
||||
// and whenever presence wins a race with the events system
|
||||
// for events regarding a newly created or visible user.
|
||||
//
|
||||
// Either way, we deal by skipping this user and
|
||||
// continuing with processing everyone else.
|
||||
continue;
|
||||
|
|
|
@ -2,17 +2,11 @@
|
|||
|
||||
const {strict: assert} = require("assert");
|
||||
|
||||
const {mock_esm, zrequire} = require("./lib/namespace");
|
||||
const {zrequire} = require("./lib/namespace");
|
||||
const {run_test} = require("./lib/test");
|
||||
const blueslip = require("./lib/zblueslip");
|
||||
const {page_params, user_settings} = require("./lib/zpage_params");
|
||||
|
||||
const reload_state = mock_esm("../src/reload_state", {
|
||||
is_in_progress: () => false,
|
||||
});
|
||||
|
||||
const people = zrequire("people");
|
||||
const watchdog = zrequire("watchdog");
|
||||
const presence = zrequire("presence");
|
||||
|
||||
const OFFLINE_THRESHOLD_SECS = 200;
|
||||
|
@ -89,24 +83,15 @@ test("my user", () => {
|
|||
assert.equal(presence.get_status(me.user_id), "active");
|
||||
});
|
||||
|
||||
test("unknown user", ({override}) => {
|
||||
test("unknown user", () => {
|
||||
const unknown_user_id = 999;
|
||||
const now = 888888;
|
||||
const presences = {};
|
||||
presences[unknown_user_id.toString()] = "does-not-matter";
|
||||
|
||||
blueslip.expect("error", "Unknown user ID in presence data");
|
||||
presence.set_info(presences, now);
|
||||
|
||||
// If the server is suspected to be offline or reloading,
|
||||
// then we suppress errors. The use case here is that we
|
||||
// haven't gotten info for a brand new user yet.
|
||||
watchdog.set_suspect_offline(true);
|
||||
presence.set_info(presences, now);
|
||||
|
||||
watchdog.set_suspect_offline(false);
|
||||
override(reload_state, "is_in_progress", () => true);
|
||||
// We just skip the unknown user.
|
||||
presence.set_info(presences, now);
|
||||
assert.equal(presence.presence_info.get(unknown_user_id), undefined);
|
||||
});
|
||||
|
||||
test("status_from_raw", () => {
|
||||
|
|
Loading…
Reference in New Issue