async get users

v1.18.x
barisusakli 9 years ago
parent f1412b6e9b
commit 0d6e1091ba

@ -89,44 +89,41 @@ var async = require('async'),
User.getUsers = function(uids, uid, callback) {
var fields = ['uid', 'username', 'userslug', 'picture', 'status', 'banned', 'joindate', 'postcount', 'reputation', 'email:confirmed', 'lastonline'];
plugins.fireHook('filter:users.addFields', {fields: fields}, function(err, data) {
if (err) {
return callback(err);
}
data.fields = data.fields.filter(function(field, index, array) {
return array.indexOf(field) === index;
});
async.parallel({
userData: function(next) {
User.getUsersFields(uids, data.fields, next);
},
isAdmin: function(next) {
User.isAdministrator(uids, next);
}
}, function(err, results) {
if (err) {
return callback(err);
}
results.userData.forEach(function(user, index) {
if (!user) {
return;
}
user.status = User.getStatus(user);
user.joindateISO = utils.toISOString(user.joindate);
user.administrator = results.isAdmin[index];
user.banned = parseInt(user.banned, 10) === 1;
user['email:confirmed'] = parseInt(user['email:confirmed'], 10) === 1;
async.waterfall([
function (next) {
plugins.fireHook('filter:users.addFields', {fields: fields}, next);
},
function (data, next) {
data.fields = data.fields.filter(function(field, index, array) {
return array.indexOf(field) === index;
});
plugins.fireHook('filter:userlist.get', {users: results.userData, uid: uid}, function(err, data) {
if (err) {
return callback(err);
async.parallel({
userData: function(next) {
User.getUsersFields(uids, data.fields, next);
},
isAdmin: function(next) {
User.isAdministrator(uids, next);
}
}, next);
},
function (results, next) {
results.userData.forEach(function(user, index) {
if (user) {
user.status = User.getStatus(user);
user.joindateISO = utils.toISOString(user.joindate);
user.administrator = results.isAdmin[index];
user.banned = parseInt(user.banned, 10) === 1;
user['email:confirmed'] = parseInt(user['email:confirmed'], 10) === 1;
}
callback(null, data.users);
});
});
});
plugins.fireHook('filter:userlist.get', {users: results.userData, uid: uid}, next);
},
function (data, next) {
next(null, data.users);
}
], callback);
};
User.getStatus = function(userData) {

Loading…
Cancel
Save