mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-05-07 17:37:11 +02:00
use getPostsFromSet for recent replies
This commit is contained in:
18
src/posts.js
18
src/posts.js
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user