mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-16 18:56:15 +01:00
use getPostsFromSet for recent replies
This commit is contained in:
@@ -13,21 +13,12 @@ var async = require('async'),
|
||||
|
||||
module.exports = function(Categories) {
|
||||
Categories.getRecentReplies = function(cid, uid, count, callback) {
|
||||
if(!parseInt(count, 10)) {
|
||||
if (!parseInt(count, 10)) {
|
||||
return callback(null, []);
|
||||
}
|
||||
|
||||
db.getSortedSetRevRange('cid:' + cid + ':pids', 0, count - 1, function(err, pids) {
|
||||
if (err || !Array.isArray(pids) || !pids.length) {
|
||||
return callback(err, []);
|
||||
}
|
||||
|
||||
async.waterfall([
|
||||
async.apply(privileges.posts.filter, 'read', pids, uid),
|
||||
function(pids, next) {
|
||||
posts.getPostSummaryByPids(pids, uid, {stripTags: true}, next);
|
||||
}
|
||||
], callback);
|
||||
posts.getPostsFromSet('cid:' + cid + ':pids', uid, 0, count - 1, function(err, data) {
|
||||
callback(err, data ? data.posts : []);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user