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) { exports.get_pm_full_names = function (message) {
function name(recip) {
if (recip.id) { function name(user_id) {
var person = people.get_person_from_user_id(recip.id); var person = people.get_person_from_user_id(user_id);
if (person) { if (!person) {
return person.full_name; blueslip.error('Unknown user id ' + user_id);
} return '?';
} }
return recip.full_name; return person.full_name;
} }
var other_recipients = _.filter(message.display_recipient, var user_ids = people.pm_with_user_ids(message);
function (element) { var names = _.map(user_ids, name).sort();
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();
return names.join(', '); return names.join(', ');
}; };