v1.18.x
barisusakli 11 years ago
parent 36dc086470
commit a3404d3d4f

@ -380,25 +380,27 @@ var async = require('async'),
}; };
Topics.getUids = function(tid, callback) { Topics.getUids = function(tid, callback) {
var uids = {};
Topics.getPids(tid, function(err, pids) { Topics.getPids(tid, function(err, pids) {
if (err) {
function getUid(pid, next) { return callback(err);
posts.getPostField(pid, 'uid', function(err, uid) {
if (err) {
return next(err);
}
uids[uid] = 1;
next();
});
} }
async.each(pids, getUid, function(err) { var keys = pids.map(function(pid) {
return 'post:' + pid;
});
db.getObjectsFields(keys, ['uid'], function(err, data) {
if (err) { if (err) {
return callback(err); return callback(err);
} }
callback(null, Object.keys(uids)); var uids = data.map(function(data) {
return data.uid;
}).filter(function(uid, pos, array) {
return array.indexOf(uid) === pos;
});
callback(null, uids);
}); });
}); });
}; };

Loading…
Cancel
Save