refactor: Simplify people.pm_reply_to().

We now call people.pm_with_user_ids() to avoid some duplicate
code.
This commit is contained in:
Steve Howell 2017-02-13 15:46:51 -08:00 committed by Tim Abbott
parent 8d3a5e7f02
commit ed4adc5650
1 changed files with 3 additions and 20 deletions

View File

@ -189,29 +189,12 @@ exports.get_recipients = function (user_ids_string) {
};
exports.pm_reply_to = function (message) {
if (message.type !== 'private') {
var user_ids = people.pm_with_user_ids(message);
if (!user_ids) {
return;
}
if (message.display_recipient.length === 0) {
blueslip.error('Empty recipient list in message');
return;
}
var user_ids = _.map(message.display_recipient, function (elem) {
return elem.user_id || elem.id;
});
var other_user_ids = _.filter(user_ids, function (user_id) {
return !people.is_my_user_id(user_id);
});
if (other_user_ids.length >= 1) {
user_ids = other_user_ids;
} else {
user_ids = [my_user_id];
}
var emails = _.map(user_ids, function (user_id) {
var person = people_by_user_id_dict.get(user_id);
if (!person) {