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.
 
 
 
 
 

33 lines
1.2 KiB

'use strict';
const quoteHandler = require(__dirname+'/quotes.js')
, { markdown } = require(__dirname+'/markdown/markdown.js')
, sanitizeOptions = require(__dirname+'/markdown/sanitizeoptions.js')
, Permission = require(__dirname+'/../permission/permission.js')
, roleManager = require(__dirname+'/../permission/rolemanager.js')
, sanitize = require('sanitize-html');
module.exports = async (inputMessage, boardName, threadId=null, permissions=null) => {
let message = inputMessage;
let quotes = [];
let crossquotes = [];
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
permissions = new Permission(roleManager.roles.ANON.base64);
}
//markdown a post, link the quotes, sanitize and return message and quote arrays
if (message && message.length > 0) {
message = markdown(message, permissions);
const { quotedMessage, threadQuotes, crossQuotes } = await quoteHandler.process(boardName, message, threadId);
message = quotedMessage;
quotes = threadQuotes;
crossquotes = crossQuotes;
message = sanitize(message, sanitizeOptions.after);
}
return { message, quotes, crossquotes };
};