|
|
@ -6,6 +6,7 @@ var user = require('../user');
|
|
|
|
var categories = require('../categories');
|
|
|
|
var categories = require('../categories');
|
|
|
|
var flags = require('../flags');
|
|
|
|
var flags = require('../flags');
|
|
|
|
var analytics = require('../analytics');
|
|
|
|
var analytics = require('../analytics');
|
|
|
|
|
|
|
|
var plugins = require('../plugins');
|
|
|
|
|
|
|
|
|
|
|
|
var modsController = module.exports;
|
|
|
|
var modsController = module.exports;
|
|
|
|
modsController.flags = {};
|
|
|
|
modsController.flags = {};
|
|
|
@ -13,6 +14,7 @@ modsController.flags = {};
|
|
|
|
modsController.flags.list = function (req, res, next) {
|
|
|
|
modsController.flags.list = function (req, res, next) {
|
|
|
|
var filters;
|
|
|
|
var filters;
|
|
|
|
var hasFilter;
|
|
|
|
var hasFilter;
|
|
|
|
|
|
|
|
var validFilters = ['assignee', 'state', 'reporterId', 'type', 'targetUid', 'cid', 'quick'];
|
|
|
|
async.waterfall([
|
|
|
|
async.waterfall([
|
|
|
|
function (next) {
|
|
|
|
function (next) {
|
|
|
|
async.parallel({
|
|
|
|
async.parallel({
|
|
|
@ -20,6 +22,16 @@ modsController.flags.list = function (req, res, next) {
|
|
|
|
moderatedCids: async.apply(user.getModeratedCids, req.uid),
|
|
|
|
moderatedCids: async.apply(user.getModeratedCids, req.uid),
|
|
|
|
}, next);
|
|
|
|
}, next);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
function (results, next) {
|
|
|
|
|
|
|
|
plugins.fireHook('filter:flags.validateFilters', { filters: validFilters }, function (err, data) {
|
|
|
|
|
|
|
|
if (err) {
|
|
|
|
|
|
|
|
return next(err);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
validFilters = data.filters;
|
|
|
|
|
|
|
|
next(null, results);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
},
|
|
|
|
function (results, next) {
|
|
|
|
function (results, next) {
|
|
|
|
if (!(results.isAdminOrGlobalMod || !!results.moderatedCids.length)) {
|
|
|
|
if (!(results.isAdminOrGlobalMod || !!results.moderatedCids.length)) {
|
|
|
|
return next(new Error('[[error:no-privileges]]'));
|
|
|
|
return next(new Error('[[error:no-privileges]]'));
|
|
|
@ -31,8 +43,8 @@ modsController.flags.list = function (req, res, next) {
|
|
|
|
|
|
|
|
|
|
|
|
// Parse query string params for filters
|
|
|
|
// Parse query string params for filters
|
|
|
|
hasFilter = false;
|
|
|
|
hasFilter = false;
|
|
|
|
var valid = ['assignee', 'state', 'reporterId', 'type', 'targetUid', 'cid', 'quick'];
|
|
|
|
|
|
|
|
filters = valid.reduce(function (memo, cur) {
|
|
|
|
filters = validFilters.reduce(function (memo, cur) {
|
|
|
|
if (req.query.hasOwnProperty(cur)) {
|
|
|
|
if (req.query.hasOwnProperty(cur)) {
|
|
|
|
memo[cur] = req.query[cur];
|
|
|
|
memo[cur] = req.query[cur];
|
|
|
|
}
|
|
|
|
}
|
|
|
|