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

View File

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