From b04a11055f654badc5dabd7f4dac3b2e988a38d5 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Tue, 17 Sep 2024 11:58:42 -0400 Subject: [PATCH] fix: re-use already parsed html in api.posts.edit's call to getPostSummaryByPids, delay federating out edit activity for 5s to give link preview a chance to resolve --- src/api/posts.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/api/posts.js b/src/api/posts.js index 259fcf6407..e56a4a125b 100644 --- a/src/api/posts.js +++ b/src/api/posts.js @@ -143,13 +143,16 @@ postsAPI.edit = async function (caller, data) { newTitle: validator.escape(String(editResult.topic.title)), }); } - const postObj = await posts.getPostSummaryByPids([editResult.post.pid], caller.uid, { extraFields: ['edited'] }); + const postObj = await posts.getPostSummaryByPids([editResult.post.pid], caller.uid, { parse: false, extraFields: ['edited'] }); + postObj.content = editResult.post.content; // re-use already parsed html const returnData = { ...postObj[0], ...editResult.post }; returnData.topic = { ...postObj[0].topic, ...editResult.post.topic }; if (!editResult.post.deleted) { websockets.in(`topic_${editResult.topic.tid}`).emit('event:post_edited', editResult); - await require('.').activitypub.update.note(caller, { post: postObj[0] }); + setTimeout(() => { + require('.').activitypub.update.note(caller, { post: postObj[0] }); + }, 5000); return returnData; }