started #961, first pass

v1.18.x
Julian Lam 11 years ago
parent d2bed7791c
commit e176abae50

@ -2,6 +2,7 @@ var db = require('./database'),
posts = require('./posts'), posts = require('./posts'),
utils = require('./../public/src/utils'), utils = require('./../public/src/utils'),
user = require('./user'), user = require('./user'),
Groups = require('./groups'),
topics = require('./topics'), topics = require('./topics'),
plugins = require('./plugins'), plugins = require('./plugins'),
CategoryTools = require('./categoryTools'), CategoryTools = require('./categoryTools'),
@ -186,10 +187,10 @@ var db = require('./database'),
}; };
Categories.getModerators = function(cid, callback) { Categories.getModerators = function(cid, callback) {
db.getSetMembers('cid:' + cid + ':moderators', function(err, mods) { Groups.getByGroupName('cid:' + cid + ':moderators', {}, function(err, groupObj) {
if (!err) { if (!err) {
if (mods && mods.length) { if (groupObj.members && groupObj.members.length) {
user.getMultipleUserFields(mods, ['uid', 'username', 'userslug', 'picture'], function(err, moderators) { user.getMultipleUserFields(groupObj.members, ['uid', 'username', 'userslug', 'picture'], function(err, moderators) {
callback(err, moderators); callback(err, moderators);
}); });
} else { } else {
@ -198,7 +199,6 @@ var db = require('./database'),
} else { } else {
callback(err, null); callback(err, null);
} }
}); });
}; };

@ -74,13 +74,9 @@ var DebugRoute = function(app) {
}); });
app.get('/test', function(req, res) { app.get('/test', function(req, res) {
// categories.getModerators(1, function(err, mods) {
var db = require('./../database'); // res.json(mods);
// })
db.getSortedSetRevRange('topics:recent', 0 , -1, function(err, tids) {
res.json(tids);
});
}); });
}); });

@ -753,11 +753,11 @@ var bcrypt = require('bcryptjs'),
}; };
User.isModerator = function(uid, cid, callback) { User.isModerator = function(uid, cid, callback) {
db.isSetMember('cid:' + cid + ':moderators', uid, function(err, exists) { groups.isMemberByGroupName(uid, 'cid:' + cid + ':moderators', function(err, isMember) {
if(err) { if(err) {
return calback(err); return calback(err);
} }
callback(err, exists); callback(err, isMember);
}); });
}; };

Loading…
Cancel
Save