adding moderator checking to post actions

v1.18.x
Julian Lam 12 years ago
parent 122d43d37f
commit 6dd960d6c3

@ -397,8 +397,27 @@ marked.setOptions({
if (uid === author) success();
else {
user.getUserField(uid, 'reputation', function(reputation) {
if (reputation >= config.privilege_thresholds.manage_content) success();
async.parallel([
function(callback) {
user.getUserField(uid, 'reputation', function(reputation) {
callback(null, reputation >= config.privilege_thresholds.manage_content);
});
},
function(callback) {
RDB.get('tid:' + tid + ':cid', function(err, cid) {
user.isModerator(uid, cid, function(isMod) {
callback(null, isMod);
});
});
}
], function(err, results) {
// If any return true, allow the edit
for(var x=0,numResults=results.length;x<numResults;x++) {
if (results[x]) {
success();
break;
}
}
});
}
});
@ -416,8 +435,27 @@ marked.setOptions({
if (uid === author) success();
else {
user.getUserField(uid, 'reputation', function(reputation) {
if (reputation >= config.privilege_thresholds.manage_content) success();
async.parallel([
function(callback) {
user.getUserField(uid, 'reputation', function(reputation) {
callback(null, reputation >= config.privilege_thresholds.manage_content);
});
},
function(callback) {
RDB.get('tid:' + tid + ':cid', function(err, cid) {
user.isModerator(uid, cid, function(isMod) {
callback(null, isMod);
});
});
}
], function(err, results) {
// If any return true, allow the edit
for(var x=0,numResults=results.length;x<numResults;x++) {
if (results[x]) {
success();
break;
}
}
});
}
});
@ -435,8 +473,27 @@ marked.setOptions({
if (uid === author) success();
else {
user.getUserField(uid, 'reputation', function(reputation) {
if (reputation >= config.privilege_thresholds.manage_content) success();
async.parallel([
function(callback) {
user.getUserField(uid, 'reputation', function(reputation) {
callback(null, reputation >= config.privilege_thresholds.manage_content);
});
},
function(callback) {
RDB.get('tid:' + tid + ':cid', function(err, cid) {
user.isModerator(uid, cid, function(isMod) {
callback(null, isMod);
});
});
}
], function(err, results) {
// If any return true, allow the edit
for(var x=0,numResults=results.length;x<numResults;x++) {
if (results[x]) {
success();
break;
}
}
});
}
});

@ -511,7 +511,7 @@ var config = require('../config.js'),
}
User.isModerator = function(uid, cid, callback) {
RDB.sismember(uid, 'cid:' + cid + ':moderators', function(err, exists) {
RDB.sismember('cid:' + cid + ':moderators', uid, function(err, exists) {
callback(exists);
});
}

Loading…
Cancel
Save