mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-07-01 00:38:03 +02:00
linting
This commit is contained in:
@@ -45,7 +45,7 @@ flagsController.get = function (req, res, next) {
|
||||
|
||||
// If res.locals.cids is populated, then slim down the categories list
|
||||
if (res.locals.cids) {
|
||||
results.categories = results.categories.filter(function(category) {
|
||||
results.categories = results.categories.filter(function (category) {
|
||||
return res.locals.cids.indexOf(String(category.cid)) !== -1;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -7,11 +7,11 @@ var adminFlagsController = require('./admin/flags');
|
||||
|
||||
var modsController = {};
|
||||
|
||||
modsController.flagged = function(req, res, next) {
|
||||
modsController.flagged = function (req, res, next) {
|
||||
async.parallel([
|
||||
async.apply(user.isAdminOrGlobalMod, req.uid),
|
||||
async.apply(user.isModeratorOfAnyCategory, req.uid)
|
||||
], function(err, results) {
|
||||
], function (err, results) {
|
||||
if (err || !(results[0] || results[1])) {
|
||||
return next(err);
|
||||
}
|
||||
|
||||
@@ -71,9 +71,9 @@ module.exports = function (Posts) {
|
||||
});
|
||||
} else {
|
||||
// Multiple cids
|
||||
async.map(cid, function(cid, next) {
|
||||
async.map(cid, function (cid, next) {
|
||||
Posts.filterPidsByCid(pids, cid, next);
|
||||
}, function(err, pidsArr) {
|
||||
}, function (err, pidsArr) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
@@ -148,7 +148,7 @@ module.exports = function (SocketPosts) {
|
||||
async.parallel([
|
||||
async.apply(user.isAdminOrGlobalMod, socket.uid),
|
||||
async.apply(user.isModeratorOfAnyCategory, socket.uid)
|
||||
], function(err, results) {
|
||||
], function (err, results) {
|
||||
next(err, results[0] || results[1]);
|
||||
});
|
||||
},
|
||||
|
||||
26
src/user.js
26
src/user.js
@@ -234,14 +234,18 @@ var meta = require('./meta');
|
||||
privileges.users.isModerator(uid, cid, callback);
|
||||
};
|
||||
|
||||
User.isModeratorOfAnyCategory = function(uid, callback) {
|
||||
User.isModeratorOfAnyCategory = function (uid, callback) {
|
||||
// Checks all active categories and determines whether passed-in uid is a mod of any of them
|
||||
db.getSortedSetRange('categories:cid', 0, -1, function(err, cids) {
|
||||
async.filter(cids, function(cid, next) {
|
||||
User.isModerator(uid, cid, function(err, isMod) {
|
||||
db.getSortedSetRange('categories:cid', 0, -1, function (err, cids) {
|
||||
async.filter(cids, function (cid, next) {
|
||||
User.isModerator(uid, cid, function (err, isMod) {
|
||||
if (err) {
|
||||
// do nothing because async doesn't support errors in filter yet
|
||||
}
|
||||
|
||||
next(!!isMod);
|
||||
});
|
||||
}, function(result) {
|
||||
}, function (result) {
|
||||
callback(err, result);
|
||||
});
|
||||
});
|
||||
@@ -291,12 +295,12 @@ var meta = require('./meta');
|
||||
});
|
||||
};
|
||||
|
||||
User.getAdminsandGlobalModsandModerators = function(callback) {
|
||||
User.getAdminsandGlobalModsandModerators = function (callback) {
|
||||
async.parallel([
|
||||
async.apply(groups.getMembers, 'administrators', 0, -1),
|
||||
async.apply(groups.getMembers, 'Global Moderators', 0, -1),
|
||||
async.apply(User.getModeratorUids)
|
||||
], function(err, results) {
|
||||
], function (err, results) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
@@ -305,15 +309,15 @@ var meta = require('./meta');
|
||||
});
|
||||
};
|
||||
|
||||
User.getModeratorUids = function(callback) {
|
||||
User.getModeratorUids = function (callback) {
|
||||
async.waterfall([
|
||||
async.apply(db.getSortedSetRange, 'categories:cid', 0, -1),
|
||||
function(cids, next) {
|
||||
var groupNames = cids.map(function(cid) {
|
||||
function (cids, next) {
|
||||
var groupNames = cids.map(function (cid) {
|
||||
return 'cid:' + cid + ':privileges:mods';
|
||||
});
|
||||
|
||||
groups.getMembersOfGroups(groupNames, function(err, memberSets) {
|
||||
groups.getMembersOfGroups(groupNames, function (err, memberSets) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
|
||||
@@ -155,9 +155,9 @@ describe('new Translator(language)', function (){
|
||||
});
|
||||
});
|
||||
|
||||
it('should translate [[pages:users/latest]] properly', function(done) {
|
||||
it('should translate [[pages:users/latest]] properly', function (done) {
|
||||
var translator = new Translator('en_GB');
|
||||
translator.translate('[[pages:users/latest]]').then(function(translated) {
|
||||
translator.translate('[[pages:users/latest]]').then(function (translated) {
|
||||
assert.strictEqual('[[pages:users/latest]]', 'Latest Users');
|
||||
done();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user