Skip to content

Node.js based forum software built for the modern web

closes #1253

barisusaklia3404d3d4fa5
diff --git a/src/topics.js b/src/topics.js
index d453dce3e2..9635b83582 100644
--- a/src/topics.js
+++ b/src/topics.js
@@ -380,25 +380,27 @@ var async = require('async'),
};
Topics.getUids = function(tid, callback) {
- var uids = {};
Topics.getPids(tid, function(err, pids) {
-
- function getUid(pid, next) {
- posts.getPostField(pid, 'uid', function(err, uid) {
- if (err) {
- return next(err);
- }
- uids[uid] = 1;
- next();
- });
+ if (err) {
+ return callback(err);
}
- async.each(pids, getUid, function(err) {
+ var keys = pids.map(function(pid) {
+ return 'post:' + pid;
+ });
+
+ db.getObjectsFields(keys, ['uid'], function(err, data) {
if (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);
});
});
};