diff --git a/src/api/posts.js b/src/api/posts.js index 74c02a210e..a7eecaa633 100644 --- a/src/api/posts.js +++ b/src/api/posts.js @@ -190,9 +190,12 @@ async function deleteOrRestore(caller, data, params) { if (!data || !data.pid) { throw new Error('[[error:invalid-data]]'); } - const postData = await posts.tools[params.command](caller.uid, data.pid); - const results = await isMainAndLastPost(data.pid); - if (results.isMain && results.isLast) { + const [postData, { isMain, isLast }] = await Promise.all([ + posts.tools[params.command](caller.uid, data.pid), + isMainAndLastPost(data.pid), + activitypub.out.delete.note(caller.uid, data.pid), + ]); + if (isMain && isLast) { await deleteOrRestoreTopicOf(params.command, data.pid, caller); } @@ -205,11 +208,6 @@ async function deleteOrRestore(caller, data, params) { tid: postData.tid, ip: caller.ip, }); - - // Explicitly non-awaited - posts.getPostSummaryByPids([data.pid], caller.uid, { extraFields: ['edited'] }).then(([post]) => { - activitypub.out.update.note(caller.uid, post); - }); } async function deleteOrRestoreTopicOf(command, pid, caller) {