optimize privileges and assorted fixes.

* new methods
privileges.categories.filter
privileges.topics.filter
privileges.posts.filter

they take a list of ids and a privilege, and return the filtered list of
ids, faster than doing  async.filter and calling the db for each id.

* remove event listeners on recent page before adding
* group.exists works for both single group names and arrays
* helpers.allowedTo works for both a single cid and an array of cids
* moved filter:topic.post hook right before topic creation.
* moved filter:topic.reply hook right before topic reply.
This commit is contained in:
barisusakli
2014-07-29 21:51:46 -04:00
parent eeb4c9f487
commit fed8cc6d53
13 changed files with 247 additions and 133 deletions

View File

@@ -45,11 +45,11 @@ search.search = function(term, uid, callback) {
}
});
async.filter(mainPids, function(pid, next) {
privileges.posts.can('read', pid, uid, function(err, canRead) {
next(!err && canRead);
});
}, function(pids) {
privileges.posts.filter('read', mainPids, uid, function(err, pids) {
if (err) {
return callback(err);
}
posts.getPostSummaryByPids(pids, {stripTags: true, parse: false}, function(err, posts) {
if (err) {
return callback(err);