moved privilege check out of getRecentReplies

it was being called twice in api/home
v1.18.x
barisusakli 11 years ago
parent ef0740049a
commit 26d67257fe

@ -9,16 +9,7 @@ var async = require('async'),
module.exports = function(Categories) {
Categories.getRecentReplies = function(cid, uid, count, callback) {
if(count === 0 || !count) {
return callback(null, []);
}
CategoryTools.privileges(cid, uid, function(err, privileges) {
if(err) {
return callback(err);
}
if (!privileges.read) {
if(!parseInt(count, 10)) {
return callback(null, []);
}
@ -33,7 +24,6 @@ module.exports = function(Categories) {
posts.getPostSummaryByPids(pids, true, callback);
});
});
};
Categories.moveRecentReplies = function(tid, oldCid, cid, callback) {

@ -1,11 +1,24 @@
'use strict';
var categories = require('../categories'),
categoryTools = require('../categoryTools'),
meta = require('./../meta'),
user = require('./../user'),
SocketCategories = {};
SocketCategories.getRecentReplies = function(socket, tid, callback) {
categories.getRecentReplies(tid, socket.uid, 4, callback);
SocketCategories.getRecentReplies = function(socket, cid, callback) {
categoryTools.privileges(cid, socket.uid, function(err, privileges) {
if (err) {
return callback(err);
}
if (privileges && !privileges.read) {
return callback(null, []);
}
categories.getRecentReplies(cid, socket.uid, 4, callback);
});
};
SocketCategories.get = function(socket, data, callback) {

Loading…
Cancel
Save