Fix quirk with message_store.get_pm_full_names().

After Iago changed his email, you would see strings like
"You and Iago, Cordelia," which was a consequence of looking up
Iago's full name using his old email.  Now we use user ids
internally for the lookup.
This commit is contained in:
Steve Howell 2017-04-17 14:08:38 -07:00 committed by Tim Abbott
parent e9e1441217
commit 31e7472cdb
1 changed files with 9 additions and 18 deletions

View File

@ -31,27 +31,18 @@ exports.get_pm_emails = function (message) {
};
exports.get_pm_full_names = function (message) {
function name(recip) {
if (recip.id) {
var person = people.get_person_from_user_id(recip.id);
if (person) {
return person.full_name;
}
function name(user_id) {
var person = people.get_person_from_user_id(user_id);
if (!person) {
blueslip.error('Unknown user id ' + user_id);
return '?';
}
return recip.full_name;
return person.full_name;
}
var other_recipients = _.filter(message.display_recipient,
function (element) {
return !people.is_current_user(element.email);
});
if (other_recipients.length === 0) {
// private message with oneself
return name(message.display_recipient[0]);
}
var names = _.map(other_recipients, name).sort();
var user_ids = people.pm_with_user_ids(message);
var names = _.map(user_ids, name).sort();
return names.join(', ');
};