Extract sorted_other_user_ids().

This commit is contained in:
Steve Howell 2017-08-01 09:35:07 -04:00 committed by Tim Abbott
parent b4c157c644
commit b110f3bab3
1 changed files with 20 additions and 13 deletions

View File

@ -278,19 +278,9 @@ exports.pm_reply_to = function (message) {
return reply_to; return reply_to;
}; };
exports.pm_with_user_ids = function (message) { function sorted_other_user_ids(user_ids) {
if (message.type !== 'private') { // This excludes your own user id unless you're the only user
return; // (i.e. you sent a message to yourself).
}
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) { var other_user_ids = _.filter(user_ids, function (user_id) {
return !people.is_my_user_id(user_id); return !people.is_my_user_id(user_id);
@ -305,6 +295,23 @@ exports.pm_with_user_ids = function (message) {
user_ids.sort(); user_ids.sort();
return user_ids; return user_ids;
}
exports.pm_with_user_ids = function (message) {
if (message.type !== 'private') {
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;
});
return sorted_other_user_ids(user_ids);
}; };
exports.pm_with_url = function (message) { exports.pm_with_url = function (message) {