notifications: split message_is_notifiable into multiple ifs for clarity.

(imported from commit 33d1e2135a87192cc4d964db534b31ae9335595a)
This commit is contained in:
Jessica McKellar 2013-10-18 13:28:29 -04:00
parent 21b085b1d4
commit efda426b86
1 changed files with 25 additions and 7 deletions

View File

@ -301,13 +301,31 @@ exports.speaking_at_me = function (message) {
};
function message_is_notifiable(message) {
// based purely on message contents, can we notify the user about the message?
return (!message.sent_by_me &&
(message.type === "private" ||
exports.speaking_at_me(message) ||
(message.type === "stream" &&
subs.receives_notifications(message.stream)) ||
alert_words.notifies(message)));
// Based purely on message contents, can we notify the user about
// the message?
// First, does anything disqualify it from being notifiable?
if (message.sent_by_me) {
return false;
}
// Then, do any properties make it notifiable?
if (message.type === "private") {
return true;
}
if (exports.speaking_at_me(message)) {
return true;
}
if ((message.type === "stream") &&
subs.receives_notifications(message.stream)) {
return true;
}
if (alert_words.notifies(message)) {
return true;
}
// Nope.
return false;
}
exports.received_messages = function (messages) {