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.
43 lines
1.2 KiB
43 lines
1.2 KiB
'use strict';
|
|
|
|
const { CustomPages } = require(__dirname+'/../../db/')
|
|
, dynamicResponse = require(__dirname+'/../../helpers/dynamic.js')
|
|
, buildQueue = require(__dirname+'/../../queue.js')
|
|
, { prepareMarkdown } = require(__dirname+'/../../helpers/posting/markdown.js')
|
|
, messageHandler = require(__dirname+'/../../helpers/posting/message.js');
|
|
|
|
module.exports = async (req, res, next) => {
|
|
|
|
const message = prepareMarkdown(req.body.message, false);
|
|
const { message: markdownMessage } = await messageHandler(message, null, null);
|
|
|
|
const post = {
|
|
'board': req.params.board,
|
|
'page': req.body.page,
|
|
'title': req.body.title,
|
|
'message': {
|
|
'raw': message,
|
|
'markdown': markdownMessage
|
|
},
|
|
'date': new Date(),
|
|
'edited': null, //unused currently
|
|
};
|
|
|
|
const insertedCustomPage = await CustomPages.insertOne(post);
|
|
post._id = insertedCustomPage.insertedId;
|
|
|
|
buildQueue.push({
|
|
'task': 'buildCustomPage',
|
|
'options': {
|
|
'board': res.locals.board,
|
|
'customPage': post,
|
|
}
|
|
});
|
|
|
|
return dynamicResponse(req, res, 200, 'message', {
|
|
'title': 'Success',
|
|
'message': 'Added custom page',
|
|
'redirect': `/${req.params.board}/manage/custompages.html`
|
|
});
|
|
|
|
}
|
|
|