mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-01-24 16:29:51 +01:00
filter before getting topics
This commit is contained in:
@@ -28,23 +28,6 @@ module.exports = function(Topics) {
|
||||
},
|
||||
function(tids, next) {
|
||||
getTopics(tids, uid, count, next);
|
||||
},
|
||||
function(topics, next) {
|
||||
var tids = topics.map(function(topic) {
|
||||
return topic.tid;
|
||||
});
|
||||
|
||||
privileges.topics.filter('read', tids, uid, function(err, tids) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
|
||||
topics = topics.filter(function(topic) {
|
||||
return tids.indexOf(topic.tid) !== -1;
|
||||
});
|
||||
|
||||
next(null, topics);
|
||||
});
|
||||
}
|
||||
], callback);
|
||||
};
|
||||
@@ -65,13 +48,19 @@ module.exports = function(Topics) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
topics = topics.sort(function(a, b) {
|
||||
tids = topics.sort(function(a, b) {
|
||||
return b.postcount - a.postcount;
|
||||
}).slice(0, count).map(function(topic) {
|
||||
return topic.tid;
|
||||
});
|
||||
|
||||
Topics.getTopicsByTids(topics, uid, callback);
|
||||
privileges.topics.filter('read', tids, uid, function(err, tids) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
Topics.getTopicsByTids(tids, uid, callback);
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user