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.
29 lines
828 B
29 lines
828 B
5 years ago
|
'use strict';
|
||
|
|
||
|
const uuidv4 = require('uuid/v4')
|
||
|
, path = require('path')
|
||
|
, util = require('util')
|
||
|
, fs = require('fs')
|
||
|
, unlink = util.promisify(fs.unlink)
|
||
|
, uploadDirectory = require(__dirname+'/../../helpers/uploadDirectory.js')
|
||
|
, Boards = require(__dirname+'/../../db/boards.js');
|
||
|
|
||
|
module.exports = async (req, res, next) => {
|
||
|
|
||
|
const redirect = `/${req.params.board}/manage`
|
||
|
|
||
|
await Promise.all(req.body.checkedbanners.map(async filename => {
|
||
|
unlink(uploadDirectory + filename);
|
||
|
}));
|
||
|
|
||
|
// i dont think there is a way to get the number of array items removed with $pullAll
|
||
|
// so i cant return how many banners were deleted
|
||
|
await Boards.removeBanners(req.params.board, req.body.checkedbanners);
|
||
|
|
||
|
return res.render('message', {
|
||
|
'title': 'Success',
|
||
|
'message': `Deleted banners.`,
|
||
|
'redirect': redirect
|
||
|
});
|
||
|
}
|