refactor: deleteOrRestore internal method to federate out a Delete on delete, not just purge; better adheres to FEP 4f05

This commit is contained in:
Julian Lam
2025-11-06 11:30:17 -05:00
parent e1bf80dcef
commit e6911be35d

View File

@@ -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) {