|
|
@ -9,30 +9,20 @@ var async = require('async'),
|
|
|
|
|
|
|
|
|
|
|
|
module.exports = function(Categories) {
|
|
|
|
module.exports = function(Categories) {
|
|
|
|
Categories.getRecentReplies = function(cid, uid, count, callback) {
|
|
|
|
Categories.getRecentReplies = function(cid, uid, count, callback) {
|
|
|
|
if(count === 0 || !count) {
|
|
|
|
if(!parseInt(count, 10)) {
|
|
|
|
return callback(null, []);
|
|
|
|
return callback(null, []);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CategoryTools.privileges(cid, uid, function(err, privileges) {
|
|
|
|
db.getSortedSetRevRange('categories:recent_posts:cid:' + cid, 0, count - 1, function(err, pids) {
|
|
|
|
if(err) {
|
|
|
|
if (err) {
|
|
|
|
return callback(err);
|
|
|
|
return callback(err, []);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!privileges.read) {
|
|
|
|
if (!pids || !pids.length) {
|
|
|
|
return callback(null, []);
|
|
|
|
return callback(null, []);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
db.getSortedSetRevRange('categories:recent_posts:cid:' + cid, 0, count - 1, function(err, pids) {
|
|
|
|
posts.getPostSummaryByPids(pids, true, callback);
|
|
|
|
if (err) {
|
|
|
|
|
|
|
|
return callback(err, []);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!pids || !pids.length) {
|
|
|
|
|
|
|
|
return callback(null, []);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
posts.getPostSummaryByPids(pids, true, callback);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|