mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-12-17 14:00:29 +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) {
|
||||
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) {
|
||||
|
||||
Reference in New Issue
Block a user