fix: cache detection logic in context parseItem executing earlier than needed causing false positives

This commit is contained in:
Julian Lam
2026-01-21 10:51:15 -05:00
parent beb3f8ff94
commit f9affbad58

View File

@@ -143,14 +143,6 @@ async function parseString(uid, item) {
} }
async function parseItem(uid, item) { 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) {
// Already cached
return postData;
}
// Handle activity wrapper // Handle activity wrapper
if (item.type === 'Create') { if (item.type === 'Create') {
item = item.object; item = item.object;
@@ -162,6 +154,14 @@ async function parseItem(uid, item) {
return null; return null;
} }
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) {
// Already cached
return postData;
}
activitypub.helpers.log(`[activitypub/context] Parsing ${pid}`); activitypub.helpers.log(`[activitypub/context] Parsing ${pid}`);
return await activitypub.mocks.post(item); return await activitypub.mocks.post(item);
} }