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.
35 lines
1.1 KiB
35 lines
1.1 KiB
3 years ago
|
|
||
4 years ago
|
'use strict';
|
||
|
|
||
4 years ago
|
const quoteHandler = require(__dirname+'/quotes.js')
|
||
4 years ago
|
, { markdown } = require(__dirname+'/markdown.js')
|
||
|
, sanitizeOptions = require(__dirname+'/sanitizeoptions.js')
|
||
2 years ago
|
, Permission = require(__dirname+'/../permission.js')
|
||
3 years ago
|
, roleManager = require(__dirname+'/../rolemanager.js')
|
||
4 years ago
|
, sanitize = require('sanitize-html');
|
||
|
|
||
3 years ago
|
module.exports = async (inputMessage, boardName, threadId=null, permissions=null) => {
|
||
4 years ago
|
|
||
|
let message = inputMessage;
|
||
|
let quotes = [];
|
||
|
let crossquotes = [];
|
||
|
|
||
3 years ago
|
if (permissions === null) {
|
||
|
//technically there has for a long time been a bug here, but it can be fixed later. permissions unknown for old msgs
|
||
3 years ago
|
permissions = new Permission(roleManager.roles.ANON.base64);
|
||
3 years ago
|
}
|
||
|
|
||
4 years ago
|
//markdown a post, link the quotes, sanitize and return message and quote arrays
|
||
|
if (message && message.length > 0) {
|
||
3 years ago
|
message = markdown(message, permissions);
|
||
4 years ago
|
const { quotedMessage, threadQuotes, crossQuotes } = await quoteHandler.process(boardName, message, threadId);
|
||
4 years ago
|
message = quotedMessage;
|
||
|
quotes = threadQuotes;
|
||
|
crossquotes = crossQuotes;
|
||
|
message = sanitize(message, sanitizeOptions.after);
|
||
|
}
|
||
|
|
||
|
return { message, quotes, crossquotes };
|
||
|
|
||
|
}
|