improve remarkup tool to uspport multiple posts

merge-requests/208/head
fatchan 4 years ago
parent 58d26a5e82
commit ea814a4dc6
  1. 13
      remarkup.js

@ -15,11 +15,14 @@ const Mongo = require(__dirname+'/db/db.js');
, sanitizeOptions = require(__dirname+'/helpers/posting/sanitizeoptions.js') , sanitizeOptions = require(__dirname+'/helpers/posting/sanitizeoptions.js')
, sanitize = require('sanitize-html'); , sanitize = require('sanitize-html');
const post = await Posts.db.findOne({/*post query here*/}); const posts = await Posts.db.find({/*query here*/}).toArray();
let message = markdown(post.nomarkup); await Promise.all(posts.map(async (post) => {
const { quotedMessage, threadQuotes, crossQuotes } = await linkQuotes('tech', message, null); let message = markdown(post.nomarkup);
message = sanitize(quotedMessage, sanitizeOptions.after); const { quotedMessage, threadQuotes, crossQuotes } = await linkQuotes(post.board, message, null);
await Posts.db.updateOne({board:'tech', postId:357}, {$set:{message:message}}); message = sanitize(quotedMessage, sanitizeOptions.after);
console.log(post.postId, message.substring(0,10)+'...');
return Posts.db.updateOne({board:post.board, postId:post.postId}, {$set:{message:message}});
}));
})(); })();

Loading…
Cancel
Save