Skip to content

Node.js based forum software built for the modern web

fix: guard against incomplete objects when building context/chain

Julian Lam13422bc8220f
diff --git a/src/activitypub/contexts.js b/src/activitypub/contexts.js
index 9b88104a38..8335ae7cc4 100644
--- a/src/activitypub/contexts.js
+++ b/src/activitypub/contexts.js
@@ -124,7 +124,7 @@ async function parseString(uid, item) {
const { type, id } = await activitypub.helpers.resolveLocalId(item);
const pid = type === 'post' && id ? id : item;
const postData = await posts.getPostData(pid);
- if (postData) {
+ if (postData && postData.pid) {
// Already cached
return postData;
}
@@ -157,7 +157,7 @@ async function parseItem(uid, item) {
const { type, id } = await activitypub.helpers.resolveLocalId(item.id);
const pid = type === 'post' && id ? id : item.id;
const postData = await posts.getPostData(pid);
- if (postData) {
+ if (postData && postData.pid) {
// Already cached
return postData;
}
diff --git a/src/activitypub/notes.js b/src/activitypub/notes.js
index 12b72494b8..56c1776318 100644
--- a/src/activitypub/notes.js
+++ b/src/activitypub/notes.js
@@ -536,7 +536,7 @@ Notes.getParentChain = async (uid, input) => {
}
const postData = await posts.getPostData(id);
- if (postData) {
+ if (postData && postData.pid) {
chain.add(postData);
if (postData.toPid) {
await traverse(uid, postData.toPid);