|
|
@ -239,36 +239,32 @@ var bcrypt = require('bcryptjs'),
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
User.getUsers = function(uids, callback) {
|
|
|
|
User.getUsers = function(uids, callback) {
|
|
|
|
function loadUserInfo(user, callback) {
|
|
|
|
async.parallel({
|
|
|
|
if (!user) {
|
|
|
|
userData: function(next) {
|
|
|
|
return callback(null, user);
|
|
|
|
User.getMultipleUserFields(uids, ['uid', 'username', 'userslug', 'picture', 'status', 'banned', 'postcount', 'reputation'], next);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async.waterfall([
|
|
|
|
|
|
|
|
function(next) {
|
|
|
|
|
|
|
|
User.isAdministrator(user.uid, next);
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
function(isAdmin, next) {
|
|
|
|
isAdmin: function(next) {
|
|
|
|
user.status = !user.status ? 'online' : user.status;
|
|
|
|
User.isAdministrator(uids, next);
|
|
|
|
user.administrator = isAdmin;
|
|
|
|
|
|
|
|
user.banned = parseInt(user.banned, 10) === 1;
|
|
|
|
|
|
|
|
db.isSortedSetMember('users:online', user.uid, next);
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
function(isMember, next) {
|
|
|
|
isOnline: function(next) {
|
|
|
|
if (!isMember) {
|
|
|
|
db.isSortedSetMembers('users:online', uids, next);
|
|
|
|
user.status = 'offline';
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
next(null, user);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
], callback);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}, function(err, results) {
|
|
|
|
User.getMultipleUserFields(uids, ['uid', 'username', 'userslug', 'picture', 'status', 'banned', 'postcount', 'reputation'], function(err, usersData) {
|
|
|
|
|
|
|
|
if (err) {
|
|
|
|
if (err) {
|
|
|
|
return callback(err);
|
|
|
|
return callback(err);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
async.map(usersData, loadUserInfo, callback);
|
|
|
|
results.userData.forEach(function(user, index) {
|
|
|
|
|
|
|
|
if (!user) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
user.status = !user.status ? 'online' : user.status;
|
|
|
|
|
|
|
|
user.status = !results.isOnline[index] ? 'offline' : user.status;
|
|
|
|
|
|
|
|
user.administrator = results.isAdmin[index];
|
|
|
|
|
|
|
|
user.banned = parseInt(user.banned, 10) === 1;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
callback(err, results.userData);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
@ -410,7 +406,11 @@ var bcrypt = require('bcryptjs'),
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
User.isAdministrator = function(uid, callback) {
|
|
|
|
User.isAdministrator = function(uid, callback) {
|
|
|
|
|
|
|
|
if (Array.isArray(uid)) {
|
|
|
|
|
|
|
|
groups.isMembers(uid, 'administrators', callback);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
groups.isMember(uid, 'administrators', callback);
|
|
|
|
groups.isMember(uid, 'administrators', callback);
|
|
|
|
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
User.isOnline = function(uid, callback) {
|
|
|
|
User.isOnline = function(uid, callback) {
|
|
|
|