fix: guard against incomplete objects when building context/chain

This commit is contained in:
Julian Lam
2026-02-06 14:45:23 -05:00
parent 725107347b
commit 13422bc822
2 changed files with 3 additions and 3 deletions

View File

@@ -124,7 +124,7 @@ async function parseString(uid, item) {
const { type, id } = await activitypub.helpers.resolveLocalId(item); const { type, id } = await activitypub.helpers.resolveLocalId(item);
const pid = type === 'post' && id ? id : item; const pid = type === 'post' && id ? id : item;
const postData = await posts.getPostData(pid); const postData = await posts.getPostData(pid);
if (postData) { if (postData && postData.pid) {
// Already cached // Already cached
return postData; return postData;
} }
@@ -157,7 +157,7 @@ async function parseItem(uid, item) {
const { type, id } = await activitypub.helpers.resolveLocalId(item.id); const { type, id } = await activitypub.helpers.resolveLocalId(item.id);
const pid = type === 'post' && id ? id : item.id; const pid = type === 'post' && id ? id : item.id;
const postData = await posts.getPostData(pid); const postData = await posts.getPostData(pid);
if (postData) { if (postData && postData.pid) {
// Already cached // Already cached
return postData; return postData;
} }

View File

@@ -536,7 +536,7 @@ Notes.getParentChain = async (uid, input) => {
} }
const postData = await posts.getPostData(id); const postData = await posts.getPostData(id);
if (postData) { if (postData && postData.pid) {
chain.add(postData); chain.add(postData);
if (postData.toPid) { if (postData.toPid) {
await traverse(uid, postData.toPid); await traverse(uid, postData.toPid);