people.js: Rename realm_get -> get_active_user_for_email.

We rename this function to be more clear, and we also remove
a stray function name for `realm_get` that was for the wrong
exported function.
This commit is contained in:
Steve Howell
2017-10-26 09:52:42 -07:00
parent 2699a6aac9
commit f8f4d9cb63
3 changed files with 11 additions and 11 deletions

View File

@@ -53,11 +53,11 @@ initialize();
assert.equal(person.email, email);
person = people.get_by_email(email);
assert.equal(person.full_name, full_name);
person = people.realm_get(email);
person = people.get_active_user_for_email(email);
assert(!person);
people.add_in_realm(isaac);
assert.equal(people.get_realm_count(), 1);
person = people.realm_get(email);
person = people.get_active_user_for_email(email);
assert.equal(person.email, email);
realm_persons = people.get_realm_persons();
@@ -71,7 +71,7 @@ initialize();
// Now deactivate isaac
people.deactivate(isaac);
person = people.realm_get(email);
person = people.get_active_user_for_email(email);
assert(!person);
assert.equal(people.get_realm_count(), 0);
assert.equal(people.realm_user_is_active_human_or_bot(isaac.user_id), false);
@@ -99,7 +99,7 @@ initialize();
// Test undefined people
assert.equal(people.is_cross_realm_email('unknown@example.com'), undefined);
assert.equal(people.realm_get('unknown@example.com'), undefined);
assert.equal(people.get_active_user_for_email('unknown@example.com'), undefined);
// Test is_my_user_id function
assert.equal(people.is_my_user_id(me.user_id), true);
@@ -170,7 +170,7 @@ initialize();
// now it takes a full person object. Note that deactivate()
// won't actually make the user disappear completely.
people.deactivate(person);
person = people.realm_get('mary@example.com');
person = people.get_active_user_for_email('mary@example.com');
assert.equal(person, undefined);
person = people.get_person_from_user_id(42);
assert.equal(person.user_id, 42);
@@ -482,7 +482,7 @@ initialize();
// Do sanity checks on our data.
assert.equal(people.get_by_email(old_email).user_id, user_id);
assert.equal(people.realm_get(old_email).user_id, user_id);
assert.equal(people.get_active_user_for_email(old_email).user_id, user_id);
assert (!people.is_cross_realm_email(old_email));
assert.equal(people.get_by_email(new_email), undefined);
@@ -492,7 +492,7 @@ initialize();
// Now look up using the new email.
assert.equal(people.get_by_email(new_email).user_id, user_id);
assert.equal(people.realm_get(new_email).user_id, user_id);
assert.equal(people.get_active_user_for_email(new_email).user_id, user_id);
assert (!people.is_cross_realm_email(new_email));
var all_people = people.get_all_persons();
@@ -654,7 +654,7 @@ initialize();
people.initialize();
assert.equal(people.realm_get('alice@example.com').full_name, 'Alice');
assert.equal(people.get_active_user_for_email('alice@example.com').full_name, 'Alice');
assert(people.is_cross_realm_email('bot@example.com'));
assert(people.is_valid_email_for_compose('bot@example.com'));
assert(people.is_valid_email_for_compose('alice@example.com'));

View File

@@ -117,7 +117,7 @@ exports.would_receive_message = function (email) {
}
if (focused_recipient.type === 'stream') {
var user = people.realm_get(email);
var user = people.get_active_user_for_email(email);
var sub = stream_data.get_sub(focused_recipient.stream);
if (!sub) {
// If the stream isn't valid, there is no risk of a mix

View File

@@ -537,7 +537,7 @@ exports.is_valid_email_for_compose = function (email) {
return active_user_dict.has(person.user_id);
};
exports.realm_get = function realm_get(email) {
exports.get_active_user_for_email = function (email) {
var person = people.get_by_email(email);
if (!person) {
return undefined;
@@ -667,7 +667,7 @@ exports.filter_people_by_search_terms = function (users, search_terms) {
return filtered_users;
};
exports.get_by_name = function realm_get(name) {
exports.get_by_name = function (name) {
return people_by_name_dict.get(name);
};