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.
32 lines
754 B
32 lines
754 B
6 years ago
|
'use strict';
|
||
|
|
||
|
const Posts = require(__dirname+'/../../db-models/posts.js')
|
||
|
, hasPerms = require(__dirname+'/../../helpers/has-perms.js');
|
||
|
|
||
|
module.exports = async (req, res) => {
|
||
|
|
||
|
if (!hasPerms(req, res)) {
|
||
|
return res.status(403).render('message', {
|
||
|
'title': 'Forbidden',
|
||
|
'message': `You are not authorised to dismiss reports.`,
|
||
|
'redirect': `/${req.params.board}`
|
||
|
});
|
||
|
}
|
||
|
|
||
|
try {
|
||
|
//dismiss reports from all checked posts
|
||
|
await Posts.dismissReports(req.params.board, req.body.checked);
|
||
|
} catch (err) {
|
||
|
console.error(err);
|
||
|
return res.status(500).render('error');
|
||
|
}
|
||
|
|
||
|
//hooray!
|
||
|
return res.render('message', {
|
||
|
'title': 'Success',
|
||
|
'message': `Dismissed report(s) successfully`,
|
||
|
'redirect': `/${req.params.board}/manage`
|
||
|
});
|
||
|
|
||
|
}
|