use getPostsFromSet for recent replies

This commit is contained in:
barisusakli
2014-11-19 11:02:28 -05:00
parent 04afe7dc4b
commit 21459fff84
4 changed files with 23 additions and 32 deletions

View File

@@ -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 : []);
});
};