mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-12-22 16:30:34 +01:00
feat: handle Delete(Context) as a move to cid -1 if the remote context still exists
This commit is contained in:
@@ -199,7 +199,9 @@ inbox.delete = async (req) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (type === 'Tombstone') {
|
if (type === 'Tombstone') {
|
||||||
method = 'delete';
|
method = 'delete'; // soft delete
|
||||||
|
} else if (activitypub._constants.acceptable.contextTypes.includes(type)) {
|
||||||
|
method = 'move'; // move to cid -1
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// probably 410/404
|
// probably 410/404
|
||||||
@@ -215,10 +217,15 @@ inbox.delete = async (req) => {
|
|||||||
|
|
||||||
const [isNote, isContext/* , isActor */] = await Promise.all([
|
const [isNote, isContext/* , isActor */] = await Promise.all([
|
||||||
posts.exists(id),
|
posts.exists(id),
|
||||||
activitypub.contexts.getItems(0, id, { returnRootId: true }),
|
activitypub.contexts.getItems(0, id, { returnRootId: true }), // ⚠️ unreliable, needs better logic (Contexts.is?)
|
||||||
// db.isSortedSetMember('usersRemote:lastCrawled', object.id),
|
// db.isSortedSetMember('usersRemote:lastCrawled', object.id),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
// 'move' method only applicable for contexts
|
||||||
|
if (method === 'move' && !isContext) {
|
||||||
|
return reject('Delete', object, actor);
|
||||||
|
}
|
||||||
|
|
||||||
switch (true) {
|
switch (true) {
|
||||||
case isNote: {
|
case isNote: {
|
||||||
const cid = await posts.getCidByPid(id);
|
const cid = await posts.getCidByPid(id);
|
||||||
@@ -241,8 +248,13 @@ inbox.delete = async (req) => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const { tid, uid } = await posts.getPostFields(pid, ['tid', 'uid']);
|
const { tid, uid } = await posts.getPostFields(pid, ['tid', 'uid']);
|
||||||
|
if (method === 'move') {
|
||||||
|
activitypub.helpers.log(`[activitypub/inbox.delete] Moving tid ${tid} to cid -1.`);
|
||||||
|
await api.topics.move({ uid }, { tid, cid: -1 });
|
||||||
|
} else {
|
||||||
activitypub.helpers.log(`[activitypub/inbox.delete] Deleting tid ${tid}.`);
|
activitypub.helpers.log(`[activitypub/inbox.delete] Deleting tid ${tid}.`);
|
||||||
await api.topics[method]({ uid }, { tids: [tid] });
|
await api.topics[method]({ uid }, { tids: [tid] });
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user