|
|
@ -40,21 +40,27 @@ var utils = require('./../public/src/utils.js'),
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var data = {},
|
|
|
|
var returnData = [];
|
|
|
|
loaded = 0;
|
|
|
|
|
|
|
|
uuids = uids.filter(function(value, index, self) {
|
|
|
|
uuids = uids.filter(function(value, index, self) {
|
|
|
|
return self.indexOf(value) === index;
|
|
|
|
return self.indexOf(value) === index;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
for (var i=0, ii=uuids.length; i<ii; i++) {
|
|
|
|
function iterator(uid, callback) {
|
|
|
|
(function(user_id) {
|
|
|
|
User.getUserFields(uid, fields, function(userData) {
|
|
|
|
User.getUserFields(user_id, fields, function(user_data) {
|
|
|
|
returnData.push(userData);
|
|
|
|
data[user_id] = user_data;
|
|
|
|
callback(null);
|
|
|
|
loaded ++;
|
|
|
|
});
|
|
|
|
if (loaded == uuids.length) callback(data);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}(uuids[i]));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async.each(uuids, iterator, function(err) {
|
|
|
|
|
|
|
|
if(!err) {
|
|
|
|
|
|
|
|
callback(returnData);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
console.log(err);
|
|
|
|
|
|
|
|
callback(null);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
User.getUserData = function(uid, callback) {
|
|
|
|
User.getUserData = function(uid, callback) {
|
|
|
@ -411,23 +417,25 @@ var utils = require('./../public/src/utils.js'),
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
User.getDataForUsers = function(userIds, callback) {
|
|
|
|
User.getDataForUsers = function(uids, callback) {
|
|
|
|
var returnData = [];
|
|
|
|
var returnData = [];
|
|
|
|
|
|
|
|
|
|
|
|
if(!userIds || userIds.length === 0) {
|
|
|
|
if(!uids || !Array.isArray(uids) || uids.length === 0) {
|
|
|
|
callback(returnData);
|
|
|
|
callback(returnData);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for(var i = 0, ii = userIds.length; i < ii; ++i) {
|
|
|
|
function iterator(uids, callback) {
|
|
|
|
User.getUserData(userIds[i], function(userData) {
|
|
|
|
User.getUserData(uid, function(userData) {
|
|
|
|
returnData.push(userData);
|
|
|
|
returnData.push(userData);
|
|
|
|
|
|
|
|
|
|
|
|
if(returnData.length == userIds.length) {
|
|
|
|
callback(null);
|
|
|
|
callback(returnData);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async.each(uids, iterator, function(err) {
|
|
|
|
|
|
|
|
callback(returnData);
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
User.sendPostNotificationToFollowers = function(uid, tid, pid) {
|
|
|
|
User.sendPostNotificationToFollowers = function(uid, tid, pid) {
|
|
|
@ -455,13 +463,9 @@ var utils = require('./../public/src/utils.js'),
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// @todo check why this function checks for a callback - if there's no callback,
|
|
|
|
|
|
|
|
// it effectively does nothing
|
|
|
|
|
|
|
|
User.exists = function(userslug, callback) {
|
|
|
|
User.exists = function(userslug, callback) {
|
|
|
|
User.get_uid_by_userslug(userslug, function(exists) {
|
|
|
|
User.get_uid_by_userslug(userslug, function(exists) {
|
|
|
|
if (callback) {
|
|
|
|
callback(!!exists);
|
|
|
|
callback(!!exists);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|