getMultipleUserFields returns err now

v1.18.x
Baris Usakli 12 years ago
parent 2fc9afa4f4
commit efa8717fc5

@ -57,8 +57,8 @@ var RDB = require('./redis.js'),
} }
function getActiveUsers(next) { function getActiveUsers(next) {
user.getMultipleUserFields(active_users, ['username', 'userslug', 'picture'], function(users) { user.getMultipleUserFields(active_users, ['username', 'userslug', 'picture'], function(err, users) {
next(null, users); next(err, users);
}); });
} }
@ -112,8 +112,8 @@ var RDB = require('./redis.js'),
RDB.smembers('cid:' + cid + ':moderators', function(err, mods) { RDB.smembers('cid:' + cid + ':moderators', function(err, mods) {
if(!err) { if(!err) {
if(mods && mods.length) { if(mods && mods.length) {
user.getMultipleUserFields(mods, ['username'], function(moderators) { user.getMultipleUserFields(mods, ['username'], function(err, moderators) {
callback(null, moderators); callback(err, moderators);
}); });
} else { } else {
callback(null, []); callback(null, []);

@ -150,8 +150,7 @@ var utils = require('./../public/src/utils.js'),
User.getMultipleUserFields = function(uids, fields, callback) { User.getMultipleUserFields = function(uids, fields, callback) {
if(uids.length === 0) { if(uids.length === 0) {
callback([]); return callback(null, []);
return;
} }
var returnData = []; var returnData = [];
@ -160,22 +159,17 @@ var utils = require('./../public/src/utils.js'),
return self.indexOf(value) === index; return self.indexOf(value) === index;
}); });
function iterator(uid, callback) { function iterator(uid, next) {
User.getUserFields(uid, fields, function(err, userData) { User.getUserFields(uid, fields, function(err, userData) {
if(err) if(err)
return callback(err); return next(err);
returnData.push(userData); returnData.push(userData);
callback(null); next(null);
}); });
} }
async.eachSeries(uuids, iterator, function(err) { async.eachSeries(uuids, iterator, function(err) {
if(!err) { callback(err, returnData);
callback(returnData);
} else {
console.log(err);
callback(null);
}
}); });
} }
@ -600,7 +594,7 @@ var utils = require('./../public/src/utils.js'),
topics.getTopicField(tid, 'slug', function(err, slug) { topics.getTopicField(tid, 'slug', function(err, slug) {
var message = '<strong>' + username + '</strong> made a new post'; var message = '<strong>' + username + '</strong> made a new post';
notifications.create(message, 5, nconf.get('url') + 'topic/' + slug + '#' + pid, 'notification_'+ Date.now(), function(nid) { notifications.create(message, 5, nconf.get('relative_path') + '/topic/' + slug + '#' + pid, 'notification_'+ Date.now(), function(nid) {
notifications.push(nid, followers); notifications.push(nid, followers);
}); });
}); });

@ -144,7 +144,8 @@ var SocketIO = require('socket.io').listen(global.server, {
if (uids.length === 0) { if (uids.length === 0) {
io.sockets.in(roomName).emit('api:get_users_in_room', userList([], anonymousCount, 0)); io.sockets.in(roomName).emit('api:get_users_in_room', userList([], anonymousCount, 0));
} else { } else {
user.getMultipleUserFields(uids, ['username', 'userslug'], function(users) { user.getMultipleUserFields(uids, ['username', 'userslug'], function(err, users) {
if(!err)
io.sockets.in(roomName).emit('api:get_users_in_room', userList(users, anonymousCount, users.length)); io.sockets.in(roomName).emit('api:get_users_in_room', userList(users, anonymousCount, users.length));
}); });
} }

Loading…
Cancel
Save