fix: fall back to inReplyTo traversal on context resolution failure

This commit is contained in:
Julian Lam
2024-10-01 10:08:19 -04:00
parent 45a0b8189b
commit 903d038919
2 changed files with 11 additions and 2 deletions

View File

@@ -79,6 +79,11 @@ Contexts.getItems = async (uid, id, options) => {
next = first; next = first;
} }
// Early breakout on empty collection
if (!chain.size) {
return [];
}
if (next) { if (next) {
winston.verbose('[activitypub/context] Fetching next page...'); winston.verbose('[activitypub/context] Fetching next page...');
Array Array

View File

@@ -49,10 +49,14 @@ Notes.assert = async (uid, input, options = { skipChecks: false }) => {
return { tid, count: 0 }; return { tid, count: 0 };
} else if (context.context) { } else if (context.context) {
chain = Array.from(await activitypub.contexts.getItems(uid, context.context, { input })); chain = Array.from(await activitypub.contexts.getItems(uid, context.context, { input }));
} else { }
// Fall back to inReplyTo traversal
if (!chain) {
// Fall back to inReplyTo traversal on context retrieval failure
chain = Array.from(await Notes.getParentChain(uid, input)); chain = Array.from(await Notes.getParentChain(uid, input));
} }
// Can't resolve — give up.
if (!chain.length) { if (!chain.length) {
unlock(id); unlock(id);
return null; return null;