mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-01-06 07:40:43 +01:00
Merge branch 'master' of https://github.com/designcreateplay/NodeBB
This commit is contained in:
@@ -2,9 +2,11 @@ var db = require('./database.js'),
|
||||
posts = require('./posts.js'),
|
||||
utils = require('./../public/src/utils.js'),
|
||||
user = require('./user.js'),
|
||||
async = require('async'),
|
||||
topics = require('./topics.js'),
|
||||
plugins = require('./plugins'),
|
||||
CategoryTools = require('./categoryTools'),
|
||||
|
||||
async = require('async'),
|
||||
winston = require('winston'),
|
||||
nconf = require('nconf');
|
||||
|
||||
@@ -210,28 +212,34 @@ var db = require('./database.js'),
|
||||
});
|
||||
};
|
||||
|
||||
Categories.getRecentReplies = function(cid, count, callback) {
|
||||
Categories.getRecentReplies = function(cid, uid, count, callback) {
|
||||
if(count === 0) {
|
||||
return callback(null, []);
|
||||
}
|
||||
|
||||
db.getSortedSetRevRange('categories:recent_posts:cid:' + cid, 0, count - 1, function(err, pids) {
|
||||
CategoryTools.privileges(cid, uid, function(err, privileges) {
|
||||
if (privileges.read) {
|
||||
db.getSortedSetRevRange('categories:recent_posts:cid:' + cid, 0, count - 1, function(err, pids) {
|
||||
|
||||
if (err) {
|
||||
winston.err(err);
|
||||
return callback(err, []);
|
||||
if (err) {
|
||||
winston.err(err);
|
||||
return callback(err, []);
|
||||
}
|
||||
|
||||
if (pids.length === 0) {
|
||||
return callback(null, []);
|
||||
}
|
||||
|
||||
posts.getPostSummaryByPids(pids, true, function(err, postData) {
|
||||
if(err) {
|
||||
return callback(err);
|
||||
}
|
||||
callback(null, postData);
|
||||
});
|
||||
});
|
||||
} else {
|
||||
callback(null, []);
|
||||
}
|
||||
|
||||
if (pids.length === 0) {
|
||||
return callback(null, []);
|
||||
}
|
||||
|
||||
posts.getPostSummaryByPids(pids, true, function(err, postData) {
|
||||
if(err) {
|
||||
return callback(err);
|
||||
}
|
||||
callback(null, postData);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ var path = require('path'),
|
||||
});
|
||||
|
||||
function iterator(category, callback) {
|
||||
categories.getRecentReplies(category.cid, parseInt(category.numRecentReplies, 10), function (err, posts) {
|
||||
categories.getRecentReplies(category.cid, uid, parseInt(category.numRecentReplies, 10), function (err, posts) {
|
||||
category.posts = posts;
|
||||
category.post_count = posts.length > 2 ? 2 : posts.length; // this was a hack to make metro work back in the day, post_count should just = length
|
||||
callback(null);
|
||||
|
||||
@@ -758,7 +758,7 @@ websockets.init = function(io) {
|
||||
});
|
||||
|
||||
socket.on('api:categories.getRecentReplies', function(tid) {
|
||||
categories.getRecentReplies(tid, 4, function(err, replies) {
|
||||
categories.getRecentReplies(tid, uid, 4, function(err, replies) {
|
||||
socket.emit('api:categories.getRecentReplies', replies);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user