From 8c17de4221d3729f3feb87b3117385e39e9688d8 Mon Sep 17 00:00:00 2001 From: barisusakli Date: Sun, 27 Sep 2015 15:02:04 -0400 Subject: [PATCH] remove dupe --- src/privileges/categories.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/privileges/categories.js b/src/privileges/categories.js index bad14d3294..b5f17eca40 100644 --- a/src/privileges/categories.js +++ b/src/privileges/categories.js @@ -301,16 +301,18 @@ module.exports = function(privileges) { }; privileges.categories.give = function(privileges, cid, groupName, callback) { - async.each(privileges, function(privilege, next) { - groups.join('cid:' + cid + ':privileges:groups:' + privilege, groupName, next); - }, callback); + giveOrRescind(groups.join, privileges, groupName, callback); }; privileges.categories.rescind = function(privileges, cid, groupName, callback) { + giveOrRescind(groups.leave, privileges, groupName, callback); + }; + + function giveOrRescind(method, privileges, cid, groupName, callback) { async.each(privileges, function(privilege, next) { - groups.leave('cid:' + cid + ':privileges:groups:' + privilege, groupName, next); + method('cid:' + cid + ':privileges:groups:' + privilege, groupName, next); }, callback); - }; + } privileges.categories.canMoveAllTopics = function(currentCid, targetCid, uid, callback) { async.parallel({