From 835ad3ea537e80baad35e90b6b438b037f03cfa4 Mon Sep 17 00:00:00 2001 From: barisusakli Date: Sat, 24 Jan 2015 13:16:07 -0500 Subject: [PATCH] fix post.getUpvoters to work with an array --- src/socket.io/posts.js | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/socket.io/posts.js b/src/socket.io/posts.js index 4a8e5f19bd..f6b599884e 100644 --- a/src/socket.io/posts.js +++ b/src/socket.io/posts.js @@ -347,17 +347,20 @@ SocketPosts.getUpvoters = function(socket, pids, callback) { if (err || !Array.isArray(data) || !data.length) { return callback(err, []); } - var otherCount = 0; - if (data[0].length > 6) { - otherCount = data[0].length - 5; - data[0] = data[0].slice(0, 5); - } - user.getUsernamesByUids(data[0], function(err, usernames) { - callback(err, { - otherCount: otherCount, - usernames: usernames + + async.map(data, function(uids, next) { + var otherCount = 0; + if (uids.length > 6) { + otherCount = uids.length - 5; + uids = uids.slice(0, 5); + } + user.getUsernamesByUids(uids, function(err, usernames) { + next(err, { + otherCount: otherCount, + usernames: usernames + }); }); - }); + }, callback); }); };