diff --git a/src/controllers/mods.js b/src/controllers/mods.js index 98990e97ba..6ca2d1d7ac 100644 --- a/src/controllers/mods.js +++ b/src/controllers/mods.js @@ -6,6 +6,7 @@ var user = require('../user'); var categories = require('../categories'); var flags = require('../flags'); var analytics = require('../analytics'); +var plugins = require('../plugins'); var modsController = module.exports; modsController.flags = {}; @@ -13,6 +14,7 @@ modsController.flags = {}; modsController.flags.list = function (req, res, next) { var filters; var hasFilter; + var validFilters = ['assignee', 'state', 'reporterId', 'type', 'targetUid', 'cid', 'quick']; async.waterfall([ function (next) { async.parallel({ @@ -20,6 +22,16 @@ modsController.flags.list = function (req, res, next) { moderatedCids: async.apply(user.getModeratedCids, req.uid), }, 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) { if (!(results.isAdminOrGlobalMod || !!results.moderatedCids.length)) { return next(new Error('[[error:no-privileges]]')); @@ -31,8 +43,8 @@ modsController.flags.list = function (req, res, next) { // Parse query string params for filters 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)) { memo[cur] = req.query[cur]; }