util: Create and use is_pm_recipient helper function.

This commit is contained in:
Tim Abbott
2016-06-07 21:06:57 -07:00
parent 60f6616030
commit a829366733
2 changed files with 6 additions and 2 deletions

View File

@@ -121,8 +121,7 @@ exports.would_receive_message = function (email) {
}
// PM, so check if the given email is in the recipients list.
var recipients = focused_recipient.reply_to.toLowerCase().split(',');
return recipients.indexOf(email.toLowerCase()) !== -1;
return util.is_pm_recipient(email, focused_recipient);
};
function _fade_users() {

View File

@@ -65,6 +65,11 @@ exports.is_current_user = function (email) {
return email.toLowerCase() === page_params.email.toLowerCase();
};
exports.is_pm_recipient = function (email, message) {
var recipients = message.reply_to.toLowerCase().split(',');
return recipients.indexOf(email.toLowerCase()) !== -1;
};
exports.same_major_recipient = function (a, b) {
// Same behavior as same_recipient, except that it returns true for messages
// on different topics but the same stream.