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.
25 lines
535 B
25 lines
535 B
'use strict';
|
|
|
|
const Boards = require(__dirname+'/../../db/boards.js');
|
|
|
|
module.exports = async (req, res, next) => {
|
|
|
|
if (!req.query.board || typeof req.query.board !== 'string') {
|
|
return next();
|
|
}
|
|
|
|
let banner;
|
|
try {
|
|
banner = await Boards.randomBanner(req.query.board);
|
|
} catch (err) {
|
|
return next(err);
|
|
}
|
|
|
|
if (!banner) {
|
|
//non existing boards will show default banner, but it doesnt really matter.
|
|
return res.redirect('/file/defaultbanner.png');
|
|
}
|
|
|
|
return res.redirect(`/banner/${req.query.board}/${banner}`);
|
|
|
|
};
|
|
|