mirror of https://gitgud.io/fatchan/jschan.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
1.1 KiB
48 lines
1.1 KiB
5 years ago
|
'use strict';
|
||
|
|
||
5 years ago
|
const removeBans = require(__dirname+'/../../models/forms/removebans.js')
|
||
|
, denyAppeals = require(__dirname+'/../../models/forms/denybanappeals.js');
|
||
5 years ago
|
|
||
|
module.exports = async (req, res, next) => {
|
||
|
|
||
|
const errors = [];
|
||
|
|
||
|
if (!req.body.checkedbans || req.body.checkedbans.length === 0 || req.body.checkedbans.length > 10) {
|
||
|
errors.push('Must select 1-10 bans')
|
||
|
}
|
||
5 years ago
|
if (!req.body.option || (req.body.option !== 'unban' && req.body.option !== 'deny_appeal')) {
|
||
|
errors.push('Invalid ban action')
|
||
|
}
|
||
5 years ago
|
|
||
5 years ago
|
const redirect = req.params.board ? `/${req.params.board}/manage/bans.html` : '/globalmanage/bans.html';
|
||
5 years ago
|
|
||
|
if (errors.length > 0) {
|
||
|
return res.status(400).render('message', {
|
||
|
'title': 'Bad request',
|
||
|
'errors': errors,
|
||
|
redirect
|
||
|
});
|
||
|
}
|
||
|
|
||
|
let amount = 0;
|
||
5 years ago
|
let message;
|
||
5 years ago
|
try {
|
||
5 years ago
|
if (req.body.option === 'unban') {
|
||
|
amount = await removeBans(req, res, next);
|
||
|
message = `Removed ${amount} bans`;
|
||
|
} else {
|
||
|
amount = await denyAppeals(req, res, next);
|
||
|
message = `Denied ${amount} appeals`;
|
||
|
}
|
||
5 years ago
|
} catch (err) {
|
||
|
return next(err);
|
||
|
}
|
||
|
|
||
|
return res.render('message', {
|
||
|
'title': 'Success',
|
||
5 years ago
|
message,
|
||
5 years ago
|
redirect
|
||
|
});
|
||
|
|
||
|
}
|