early outs for privs

no need to check if empty array is passed in, happens if there are no
unread topics
remove dupe cids before checking for privileges
v1.18.x
barisusakli 11 years ago
parent 7bfec99df1
commit 1398937dd8

@ -68,6 +68,14 @@ module.exports = function(privileges) {
};
privileges.categories.filter = function(privilege, cids, uid, callback) {
if (!cids.length) {
return callback(null, []);
}
cids = cids.filter(function(cid, index, array) {
return array.indexOf(cid) === index;
});
async.parallel({
allowedTo: function(next) {
helpers.allowedTo(privilege, uid, cids, next);

@ -77,6 +77,9 @@ module.exports = function(privileges) {
};
privileges.posts.filter = function(privilege, pids, uid, callback) {
if (!pids.length) {
return callback(null, []);
}
posts.getCidsByPids(pids, function(err, cids) {
if (err) {
return callback(err);

@ -76,6 +76,10 @@ module.exports = function(privileges) {
};
privileges.topics.filter = function(privilege, tids, uid, callback) {
if (!tids.length) {
return callback(null, []);
}
var keys = tids.map(function(tid) {
return 'topic:' + tid;
});

Loading…
Cancel
Save