jschan - Anonymous imageboard software. Classic look, modern features and feel. Works without JavaScript and supports Tor, I2P, Lokinet, etc.
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.
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const { buildThread } = require(__dirname+'/../../helpers/tasks.js');
|
|
|
|
|
|
|
|
module.exports = async (req, res, next) => {
|
|
|
|
|
|
|
|
let html, json;
|
|
|
|
try {
|
|
|
|
const buildThreadData = await buildThread({
|
|
|
|
threadId: res.locals.thread.postId,
|
|
|
|
board: res.locals.board
|
|
|
|
});
|
|
|
|
/* unlikely, but postsExists middleware can be true, but this can be null if deleted. so just next() to 404
|
|
|
|
wont matter in the build-workers that call this because they dont destructure and never cause the bug */
|
|
|
|
if (!buildThreadData) {
|
|
|
|
return next();
|
|
|
|
}
|
|
|
|
({ html, json } = buildThreadData);
|
|
|
|
} catch (err) {
|
|
|
|
return next(err);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (req.path.endsWith('.json')) {
|
|
|
|
return res.json(json);
|
|
|
|
} else {
|
|
|
|
return res.send(html);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|