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.
37 lines
984 B
37 lines
984 B
'use strict';
|
|
|
|
const { News } = require(__dirname+'/../../db/')
|
|
, dynamicResponse = require(__dirname+'/../../lib/misc/dynamic.js')
|
|
, buildQueue = require(__dirname+'/../../lib/build/queue.js')
|
|
, { prepareMarkdown } = require(__dirname+'/../../lib/post/markdown/markdown.js')
|
|
, messageHandler = require(__dirname+'/../../lib/post/message.js');
|
|
|
|
module.exports = async (req, res) => {
|
|
|
|
const message = prepareMarkdown(req.body.message, false);
|
|
const { message: markdownNews } = await messageHandler(message, null, null, res.locals.permissions);
|
|
|
|
const post = {
|
|
'title': req.body.title,
|
|
'message': {
|
|
'raw': message,
|
|
'markdown': markdownNews
|
|
},
|
|
'date': new Date(),
|
|
'edited': null,
|
|
};
|
|
|
|
await News.insertOne(post);
|
|
|
|
buildQueue.push({
|
|
'task': 'buildNews',
|
|
'options': {}
|
|
});
|
|
|
|
return dynamicResponse(req, res, 200, 'message', {
|
|
'title': res.locals.__('Success'),
|
|
'message': res.locals.__('Added newspost'),
|
|
'redirect': '/globalmanage/news.html'
|
|
});
|
|
|
|
};
|
|
|