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

@@ -8,6 +8,7 @@ var async = require('async'),
user = require('./user'),
topics = require('./topics'),
postTools = require('./postTools'),
privileges = require('./privileges'),
plugins = require('./plugins');
(function(Posts) {
@@ -85,6 +86,23 @@ var async = require('async'),
});
};
Posts.getPostsFromSet = function(set, uid, start, end, callback) {
async.waterfall([
function(next) {
db.getSortedSetRevRange(set, start, end, next);
},
function(pids, next) {
privileges.posts.filter('read', pids, uid, next);
},
function(pids, next) {
Posts.getPostSummaryByPids(pids, uid, {stripTags: false}, next);
},
function(posts, next) {
next(null, {posts: posts, nextStart: end + 1});
}
], callback);
};
Posts.getPostData = function(pid, callback) {
db.getObject('post:' + pid, function(err, data) {
if(err) {