mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 05:53:43 +00:00 
			
		
		
		
	Rename get_realm_persons() to get_realm_users().
The function's name was misleading, since it includes any bots in your realm.
This commit is contained in:
		@@ -50,7 +50,7 @@ And then in `user_pill.js`...
 | 
			
		||||
 | 
			
		||||
```js
 | 
			
		||||
exports.typeahead_source = function (pill_widget) {
 | 
			
		||||
    const persons = people.get_realm_persons();
 | 
			
		||||
    const persons = people.get_realm_users();
 | 
			
		||||
    return exports.filter_taken_users(persons, pill_widget);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -35,7 +35,7 @@ run_test('pills', () => {
 | 
			
		||||
        full_name: 'Hamlet',
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    people.get_realm_persons = function () {
 | 
			
		||||
    people.get_realm_users = function () {
 | 
			
		||||
        return [iago, othello, hamlet];
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -50,13 +50,15 @@ function get_all_persons() {
 | 
			
		||||
run_test('basics', () => {
 | 
			
		||||
    const persons = get_all_persons();
 | 
			
		||||
 | 
			
		||||
    assert.deepEqual(people.get_realm_users(), [me]);
 | 
			
		||||
 | 
			
		||||
    assert.equal(persons.length, 1);
 | 
			
		||||
    assert.equal(persons[0].full_name, 'Me Myself');
 | 
			
		||||
 | 
			
		||||
    let realm_persons = people.get_realm_persons();
 | 
			
		||||
    let realm_persons = people.get_realm_users();
 | 
			
		||||
    assert.equal(realm_persons[0].full_name, 'Me Myself');
 | 
			
		||||
 | 
			
		||||
    realm_persons = people.get_realm_persons();
 | 
			
		||||
    realm_persons = people.get_realm_users();
 | 
			
		||||
    assert.equal(realm_persons.length, 1);
 | 
			
		||||
    assert.equal(people.get_active_human_count(), 1);
 | 
			
		||||
 | 
			
		||||
@@ -89,7 +91,7 @@ run_test('basics', () => {
 | 
			
		||||
    person = people.get_active_user_for_email(email);
 | 
			
		||||
    assert.equal(person.email, email);
 | 
			
		||||
 | 
			
		||||
    realm_persons = people.get_realm_persons();
 | 
			
		||||
    realm_persons = people.get_realm_users();
 | 
			
		||||
    assert.equal(realm_persons.length, 2);
 | 
			
		||||
 | 
			
		||||
    const active_user_ids = people.get_active_user_ids().sort();
 | 
			
		||||
@@ -114,6 +116,16 @@ run_test('basics', () => {
 | 
			
		||||
    people.add_in_realm(bot_botson);
 | 
			
		||||
    assert.equal(people.is_active_user_for_popover(bot_botson.user_id), true);
 | 
			
		||||
 | 
			
		||||
    // get_realm_users() will include our active bot,
 | 
			
		||||
    // but will exclude isaac (who is deactivated)
 | 
			
		||||
    assert.deepEqual(
 | 
			
		||||
        people.get_realm_users().map((u) => u.user_id).sort(),
 | 
			
		||||
        [
 | 
			
		||||
            me.user_id,
 | 
			
		||||
            bot_botson.user_id,
 | 
			
		||||
        ]
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    // The bot doesn't add to our human count.
 | 
			
		||||
    assert.equal(people.get_active_human_count(), 1);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -112,7 +112,7 @@ run_test('populate_user_groups', () => {
 | 
			
		||||
        full_name: 'Bob',
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    people.get_realm_persons = function () {
 | 
			
		||||
    people.get_realm_users = function () {
 | 
			
		||||
        return [iago, alice, bob];
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
@@ -344,7 +344,7 @@ run_test('with_external_user', () => {
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    // We return noop because these are already tested, so we skip them
 | 
			
		||||
    people.get_realm_persons = function () {
 | 
			
		||||
    people.get_realm_users = function () {
 | 
			
		||||
        return noop;
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -207,7 +207,7 @@ for (const person of matches) {
 | 
			
		||||
 | 
			
		||||
function get_typeahead_result(query, current_stream, current_topic) {
 | 
			
		||||
    const result = th.sort_recipients(
 | 
			
		||||
        global.people.get_realm_persons(),
 | 
			
		||||
        global.people.get_realm_users(),
 | 
			
		||||
        query,
 | 
			
		||||
        current_stream,
 | 
			
		||||
        current_topic
 | 
			
		||||
 
 | 
			
		||||
@@ -470,7 +470,7 @@ exports.get_person_suggestions = function (query, opts) {
 | 
			
		||||
        filtered_persons = filtered_message_persons;
 | 
			
		||||
    } else {
 | 
			
		||||
        filtered_persons = filter_persons(
 | 
			
		||||
            people.get_realm_persons()
 | 
			
		||||
            people.get_realm_users()
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -685,7 +685,8 @@ exports.filter_all_users = function (pred) {
 | 
			
		||||
    return ret;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
exports.get_realm_persons = function () {
 | 
			
		||||
exports.get_realm_users = function () {
 | 
			
		||||
    // includes humans and bots from your realm
 | 
			
		||||
    return Array.from(active_user_dict.values());
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
@@ -921,7 +922,7 @@ exports.get_people_for_stream_create = function () {
 | 
			
		||||
    /*
 | 
			
		||||
        If you are thinking of reusing this function,
 | 
			
		||||
        a better option in most cases is to just
 | 
			
		||||
        call `exports.get_realm_persons()` and then
 | 
			
		||||
        call `exports.get_realm_users()` and then
 | 
			
		||||
        filter out the "me" user yourself as part of
 | 
			
		||||
        any other filtering that you are doing.
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -147,7 +147,7 @@ exports.update_info_for_small_realm = function () {
 | 
			
		||||
 | 
			
		||||
    // For small realms, we create presence info for users
 | 
			
		||||
    // that the server didn't include in its presence update.
 | 
			
		||||
    const persons = people.get_realm_persons();
 | 
			
		||||
    const persons = people.get_realm_users();
 | 
			
		||||
 | 
			
		||||
    for (const person of persons) {
 | 
			
		||||
        const user_id = person.user_id;
 | 
			
		||||
 
 | 
			
		||||
@@ -86,7 +86,7 @@ exports.has_unconverted_data = function (pill_widget) {
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
exports.typeahead_source = function (pill_widget) {
 | 
			
		||||
    const persons = people.get_realm_persons();
 | 
			
		||||
    const persons = people.get_realm_users();
 | 
			
		||||
    return exports.filter_taken_users(persons, pill_widget);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user