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.
27 lines
800 B
27 lines
800 B
4 years ago
|
'use strict';
|
||
|
|
||
|
const linkQuotes = require(__dirname+'/quotes.js')
|
||
|
, { markdown } = require(__dirname+'/markdown.js')
|
||
|
, sanitizeOptions = require(__dirname+'/sanitizeoptions.js')
|
||
|
, sanitize = require('sanitize-html');
|
||
|
|
||
|
module.exports = async (inputMessage, boardName, threadId=null) => {
|
||
|
|
||
|
let message = inputMessage;
|
||
|
let quotes = [];
|
||
|
let crossquotes = [];
|
||
|
|
||
|
//markdown a post, link the quotes, sanitize and return message and quote arrays
|
||
|
if (message && message.length > 0) {
|
||
|
message = markdown(message);
|
||
|
const { quotedMessage, threadQuotes, crossQuotes } = await linkQuotes(boardName, message, threadId);
|
||
|
message = quotedMessage;
|
||
|
quotes = threadQuotes;
|
||
|
crossquotes = crossQuotes;
|
||
|
message = sanitize(message, sanitizeOptions.after);
|
||
|
}
|
||
|
|
||
|
return { message, quotes, crossquotes };
|
||
|
|
||
|
}
|