mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-03 04:25:55 +01:00
fixed #719
This commit is contained in:
@@ -2,9 +2,11 @@ var db = require('./database.js'),
|
|||||||
posts = require('./posts.js'),
|
posts = require('./posts.js'),
|
||||||
utils = require('./../public/src/utils.js'),
|
utils = require('./../public/src/utils.js'),
|
||||||
user = require('./user.js'),
|
user = require('./user.js'),
|
||||||
async = require('async'),
|
|
||||||
topics = require('./topics.js'),
|
topics = require('./topics.js'),
|
||||||
plugins = require('./plugins'),
|
plugins = require('./plugins'),
|
||||||
|
CategoryTools = require('./categoryTools'),
|
||||||
|
|
||||||
|
async = require('async'),
|
||||||
winston = require('winston'),
|
winston = require('winston'),
|
||||||
nconf = require('nconf');
|
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) {
|
if(count === 0) {
|
||||||
return callback(null, []);
|
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) {
|
if (err) {
|
||||||
winston.err(err);
|
winston.err(err);
|
||||||
return callback(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) {
|
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.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
|
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);
|
callback(null);
|
||||||
|
|||||||
@@ -758,7 +758,7 @@ websockets.init = function(io) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
socket.on('api:categories.getRecentReplies', function(tid) {
|
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);
|
socket.emit('api:categories.getRecentReplies', replies);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user