Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
presence: Remove paranoid handling of falsy timestamps.
Anders Kaseorgf88e3b973526
diff --git a/web/src/presence.ts b/web/src/presence.tsindex e70a7266cb8..3fc749b0ca8 100644--- a/web/src/presence.ts+++ b/web/src/presence.ts@@ -219,8 +219,8 @@ export function set_info(const raw: RawPresence = {server_timestamp,- active_timestamp: info.active_timestamp || undefined,- idle_timestamp: info.idle_timestamp || undefined,+ active_timestamp: info.active_timestamp,+ idle_timestamp: info.idle_timestamp,};raw_info.set(user_id, raw);diff --git a/web/tests/presence.test.js b/web/tests/presence.test.jsindex a092ccd24eb..81939269edb 100644--- a/web/tests/presence.test.js+++ b/web/tests/presence.test.js@@ -206,46 +206,36 @@ test("set_presence_info", () => {assert.equal(presence.get_status(jane.user_id), "idle");});-test("falsy values", () => {+test("missing values", () => {/*When a user does not have a relevant active timestamp,the server just leaves off the `active_timestamp` fieldto save bandwidth, which looks like `undefined` to usif we try to dereference it.-- Our code should just treat all falsy values the same way,- though, to defend against bugs where we say the person- was last online in 1970 or silly things like that.*/const now = 2000000;const a_bit_ago = now - 5;const presences = {};- for (const falsy_value of [undefined, 0, null]) {- presences[zoe.user_id.toString()] = {- active_timestamp: falsy_value,- idle_timestamp: a_bit_ago,- };+ presences[zoe.user_id.toString()] = {+ idle_timestamp: a_bit_ago,+ };- presence.set_info(presences, now);+ presence.set_info(presences, now);- assert.deepEqual(presence.presence_info.get(zoe.user_id), {- status: "idle",- last_active: a_bit_ago,- });+ assert.deepEqual(presence.presence_info.get(zoe.user_id), {+ status: "idle",+ last_active: a_bit_ago,+ });- presences[zoe.user_id.toString()] = {- active_timestamp: falsy_value,- idle_timestamp: falsy_value,- };+ presences[zoe.user_id.toString()] = {};- presence.set_info(presences, now);+ presence.set_info(presences, now);- assert.deepEqual(presence.presence_info.get(zoe.user_id), {- status: "offline",- last_active: undefined,- });- }+ assert.deepEqual(presence.presence_info.get(zoe.user_id), {+ status: "offline",+ last_active: undefined,+ });});test("big realms", ({override_rewire}) => {