feat: handle Delete(Context) as a move to cid -1 if the remote context still exists

This commit is contained in:
Julian Lam
2025-10-16 16:23:27 -04:00
parent e09bb8b611
commit f98a7216a3

View File

@@ -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']);
activitypub.helpers.log(`[activitypub/inbox.delete] Deleting tid ${tid}.`); if (method === 'move') {
await api.topics[method]({ uid }, { tids: [tid] }); 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; break;
} }