popovers: Don't show bots as deactivated in user popovers.

Apparently this is a bug that slipped in when we started showing
normal users as deactivated in the user popovers: all bot users were
treated that way as well.

We'll want to do #7153 as a follow-up to get things fully working how
we want them.
This commit is contained in:
Tim Abbott 2017-10-24 15:59:51 -07:00
parent 6ed2a9b9f2
commit 11eba1173c
3 changed files with 25 additions and 6 deletions

View File

@ -64,15 +64,23 @@ initialize();
var human_user_ids = people.get_realm_human_user_ids();
assert.deepEqual(human_user_ids, [isaac.user_id]);
assert.equal(people.realm_user_is_active_human(isaac.user_id), true);
assert.equal(people.realm_user_is_active_human_or_bot(isaac.user_id), true);
// Now deactivate isaac
people.deactivate(isaac);
person = people.realm_get(email);
assert(!person);
assert.equal(people.get_realm_count(), 0);
assert.equal(people.realm_user_is_active_human(isaac.user_id), false);
assert.equal(people.realm_user_is_active_human_or_bot(isaac.user_id), false);
var bot_botson = {
email: 'botson-bot@example.com',
user_id: 35,
full_name: 'Bot Botson',
is_bot: true,
};
people.add(bot_botson);
assert.equal(people.realm_user_is_active_human_or_bot(bot_botson.user_id), true);
// We can still get their info for non-realm needs.
person = people.get_by_email(email);

View File

@ -530,8 +530,19 @@ exports.realm_get = function realm_get(email) {
return realm_people_dict.get(person.user_id);
};
exports.realm_user_is_active_human = function (id) {
return !!realm_people_dict.get(id);
exports.realm_user_is_active_human_or_bot = function (id) {
if (realm_people_dict.get(id) !== undefined) {
return true;
}
// TODO: Technically, we should probably treat deactivated bots
// like deactivated users here. But we don't have the data to do
// that. See #7153 for notes on fixing this.
var person = exports.get_person_from_user_id(id);
if (person === undefined) {
blueslip.error("Unexpectedly invalid user ID in user popover query " + id);
return false;
}
return !!person.is_bot;
};
exports.get_all_persons = function () {

View File

@ -100,7 +100,7 @@ function show_user_info_popover(element, user, message) {
sent_by_uri: narrow.by_sender_uri(user.email),
narrowed: narrow_state.active(),
private_message_class: "respond_personal_button",
is_active: people.realm_user_is_active_human(user.user_id),
is_active: people.realm_user_is_active_human_or_bot(user.user_id),
};
var ypos = elt.offset().top;
@ -448,7 +448,7 @@ exports.register_click_handlers = function () {
pm_with_uri: narrow.pm_with_uri(user_email),
sent_by_uri: narrow.by_sender_uri(user_email),
private_message_class: "compose_private_message",
is_active: people.realm_user_is_active_human(user_id),
is_active: people.realm_user_is_active_human_or_bot(user_id),
};
target.popover({