From 515e663f8512c1dc4b42b5aceb1fe90efea3a2e4 Mon Sep 17 00:00:00 2001 From: barisusakli Date: Mon, 22 Sep 2014 21:47:20 -0400 Subject: [PATCH] getObjectsFix return empty array if keys is empty or not an array --- src/database/mongo/hash.js | 2 +- src/notifications.js | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/database/mongo/hash.js b/src/database/mongo/hash.js index d887143d89..2308892a42 100644 --- a/src/database/mongo/hash.js +++ b/src/database/mongo/hash.js @@ -32,7 +32,7 @@ module.exports = function(db, module) { module.getObjects = function(keys, callback) { if (!Array.isArray(keys) || !keys.length) { - return callback(); + return callback(null, []); } db.collection('objects').find({_key: {$in: keys}}, {_id: 0}).toArray(function(err, data) { if(err) { diff --git a/src/notifications.js b/src/notifications.js index 0e38a3eec7..3671ad1613 100644 --- a/src/notifications.js +++ b/src/notifications.js @@ -40,6 +40,10 @@ var async = require('async'), return callback(err); } + if (!Array.isArray(notifications) || !notifications.length) { + return callback(null, []); + } + async.map(notifications, function(notification, next) { if (!notification) { return next(null, null);