diff --git a/web/src/people.js b/web/src/people.js index 088d89a452..cc582de421 100644 --- a/web/src/people.js +++ b/web/src/people.js @@ -906,6 +906,19 @@ export function get_realm_users() { return [...active_user_dict.values()]; } +export function get_realm_active_human_users() { + // includes ONLY humans from your realm + const humans = []; + + for (const user of active_user_dict.values()) { + if (!user.is_bot) { + humans.push(user); + } + } + + return humans; +} + export function get_realm_active_human_user_ids() { const human_ids = []; diff --git a/web/tests/people.test.js b/web/tests/people.test.js index a1ea329460..ad65c5ad0b 100644 --- a/web/tests/people.test.js +++ b/web/tests/people.test.js @@ -1252,6 +1252,23 @@ test_people("huddle_string", () => { assert.equal(huddle([me.user_id, maria.user_id, bob.user_id]), "203,302"); }); +test_people("get_realm_active_human_users", () => { + let humans = people.get_realm_active_human_users(); + assert.equal(humans.length, 1); + assert.deepEqual(humans, [me]); + + people.add_active_user(maria); + people.add_active_user(bot_botson); + humans = people.get_realm_active_human_users(); + assert.equal(humans.length, 2); + assert.deepEqual(humans, [me, maria]); + + people.deactivate(maria); + humans = people.get_realm_active_human_users(); + assert.equal(humans.length, 1); + assert.deepEqual(humans, [me]); +}); + // reset to native Date() run_test("reset MockDate", () => { MockDate.reset();