Node.js based forum software built for the modern web
fix: resolveLocalId to return null values instead of throwing for no resolution
Julian Lam11dba85d0ae1
diff --git a/src/activitypub/helpers.js b/src/activitypub/helpers.jsindex 49f42dba31..04118b8f63 100644--- a/src/activitypub/helpers.js+++ b/src/activitypub/helpers.js@@ -107,15 +107,15 @@ Helpers.resolveLocalId = async (input) => {}}- throw new Error('[[error:activitypub.invalid-id]]');- } else {- throw new Error('[[error:activitypub.invalid-id]]');+ return { type: null, id: null };}++ return { type: null, id: null };} else if (input.indexOf('@') !== -1) { // Webfingerconst [slug] = input.replace(/^acct:/, '').split('@');const uid = await user.getUidByUserslug(slug);return { type: 'user', id: uid };}- throw new Error('[[error:activitypub.invalid-id]]');+ return { type: null, id: null };};diff --git a/src/activitypub/notes.js b/src/activitypub/notes.jsindex 4d48fcdd95..28ee228520 100644--- a/src/activitypub/notes.js+++ b/src/activitypub/notes.js@@ -53,6 +53,12 @@ Notes.getParentChain = async (uid, input) => {const chain = new Set();const traverse = async (uid, id) => {+ // Handle remote reference to local post+ const { type, id: localId } = await activitypub.helpers.resolveLocalId(id);+ if (type === 'post' && localId) {+ return traverse(uid, localId);+ }+const exists = await db.exists(`post:${id}`);if (exists) {const postData = await posts.getPostData(id);