fix post.getUpvoters to work with an array

v1.18.x
barisusakli 10 years ago
parent bc9ede7b6c
commit 835ad3ea53

@ -347,17 +347,20 @@ SocketPosts.getUpvoters = function(socket, pids, callback) {
if (err || !Array.isArray(data) || !data.length) { if (err || !Array.isArray(data) || !data.length) {
return callback(err, []); return callback(err, []);
} }
async.map(data, function(uids, next) {
var otherCount = 0; var otherCount = 0;
if (data[0].length > 6) { if (uids.length > 6) {
otherCount = data[0].length - 5; otherCount = uids.length - 5;
data[0] = data[0].slice(0, 5); uids = uids.slice(0, 5);
} }
user.getUsernamesByUids(data[0], function(err, usernames) { user.getUsernamesByUids(uids, function(err, usernames) {
callback(err, { next(err, {
otherCount: otherCount, otherCount: otherCount,
usernames: usernames usernames: usernames
}); });
}); });
}, callback);
}); });
}; };

Loading…
Cancel
Save