mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-02 12:05:57 +01:00
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
This commit is contained in:
@@ -68,6 +68,14 @@ module.exports = function(privileges) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
privileges.categories.filter = function(privilege, cids, uid, callback) {
|
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({
|
async.parallel({
|
||||||
allowedTo: function(next) {
|
allowedTo: function(next) {
|
||||||
helpers.allowedTo(privilege, uid, cids, next);
|
helpers.allowedTo(privilege, uid, cids, next);
|
||||||
|
|||||||
@@ -77,6 +77,9 @@ module.exports = function(privileges) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
privileges.posts.filter = function(privilege, pids, uid, callback) {
|
privileges.posts.filter = function(privilege, pids, uid, callback) {
|
||||||
|
if (!pids.length) {
|
||||||
|
return callback(null, []);
|
||||||
|
}
|
||||||
posts.getCidsByPids(pids, function(err, cids) {
|
posts.getCidsByPids(pids, function(err, cids) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return callback(err);
|
return callback(err);
|
||||||
|
|||||||
@@ -76,6 +76,10 @@ module.exports = function(privileges) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
privileges.topics.filter = function(privilege, tids, uid, callback) {
|
privileges.topics.filter = function(privilege, tids, uid, callback) {
|
||||||
|
if (!tids.length) {
|
||||||
|
return callback(null, []);
|
||||||
|
}
|
||||||
|
|
||||||
var keys = tids.map(function(tid) {
|
var keys = tids.map(function(tid) {
|
||||||
return 'topic:' + tid;
|
return 'topic:' + tid;
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user