From f98a7216a3feed00c80a91ee6276126bfc51158b Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Thu, 16 Oct 2025 16:23:27 -0400 Subject: [PATCH] feat: handle Delete(Context) as a move to cid -1 if the remote context still exists --- src/activitypub/inbox.js | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/activitypub/inbox.js b/src/activitypub/inbox.js index 77fd2bf4b5..9fe4a52a4d 100644 --- a/src/activitypub/inbox.js +++ b/src/activitypub/inbox.js @@ -199,7 +199,9 @@ inbox.delete = async (req) => { } 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) { // probably 410/404 @@ -215,10 +217,15 @@ inbox.delete = async (req) => { const [isNote, isContext/* , isActor */] = await Promise.all([ 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), ]); + // 'move' method only applicable for contexts + if (method === 'move' && !isContext) { + return reject('Delete', object, actor); + } + switch (true) { case isNote: { const cid = await posts.getCidByPid(id); @@ -241,8 +248,13 @@ inbox.delete = async (req) => { return; } const { tid, uid } = await posts.getPostFields(pid, ['tid', 'uid']); - activitypub.helpers.log(`[activitypub/inbox.delete] Deleting tid ${tid}.`); - await api.topics[method]({ uid }, { tids: [tid] }); + 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}.`); + await api.topics[method]({ uid }, { tids: [tid] }); + } break; }