mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-12-19 15:00:22 +01:00
refactor: deleteOrRestore internal method to federate out a Delete on delete, not just purge; better adheres to FEP 4f05
This commit is contained in:
@@ -190,9 +190,12 @@ async function deleteOrRestore(caller, data, params) {
|
|||||||
if (!data || !data.pid) {
|
if (!data || !data.pid) {
|
||||||
throw new Error('[[error:invalid-data]]');
|
throw new Error('[[error:invalid-data]]');
|
||||||
}
|
}
|
||||||
const postData = await posts.tools[params.command](caller.uid, data.pid);
|
const [postData, { isMain, isLast }] = await Promise.all([
|
||||||
const results = await isMainAndLastPost(data.pid);
|
posts.tools[params.command](caller.uid, data.pid),
|
||||||
if (results.isMain && results.isLast) {
|
isMainAndLastPost(data.pid),
|
||||||
|
activitypub.out.delete.note(caller.uid, data.pid),
|
||||||
|
]);
|
||||||
|
if (isMain && isLast) {
|
||||||
await deleteOrRestoreTopicOf(params.command, data.pid, caller);
|
await deleteOrRestoreTopicOf(params.command, data.pid, caller);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -205,11 +208,6 @@ async function deleteOrRestore(caller, data, params) {
|
|||||||
tid: postData.tid,
|
tid: postData.tid,
|
||||||
ip: caller.ip,
|
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) {
|
async function deleteOrRestoreTopicOf(command, pid, caller) {
|
||||||
|
|||||||
Reference in New Issue
Block a user