diff --git a/src/notifications.js b/src/notifications.js index 3671ad1613..3a10a5da37 100644 --- a/src/notifications.js +++ b/src/notifications.js @@ -120,6 +120,11 @@ var async = require('async'), Notifications.push = function(notification, uids, callback) { callback = callback || function() {}; + + if (!notification.nid) { + return callback(); + } + var websockets = require('./socket.io'); if (!Array.isArray(uids)) { uids = [uids]; @@ -183,7 +188,7 @@ var async = require('async'), return callback(); } - var notificationKeys = nids.map(function(nid) { + var notificationKeys = nids.filter(Boolean).map(function(nid) { return 'notifications:' + nid; }); diff --git a/src/user/notifications.js b/src/user/notifications.js index fa61fce32a..63d1ccc82f 100644 --- a/src/user/notifications.js +++ b/src/user/notifications.js @@ -71,9 +71,7 @@ var async = require('async'), winston.info('[notifications.get] nid ' + nids[index] + ' not found. Removing.'); } - if (nids[index]) { - deletedNids.push(nids[index]); - } + deletedNids.push(nids[index]); } });