Skip to content

Commit 948edc9

Browse files
authored
Merge pull request #791 from CodingCatDev/dev
fix(syndication): include Cookie header for AWS Builder and check existing syndication docs
2 parents 994cad7 + 66c9521 commit 948edc9

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

‎apps/sanity/functions/syndicate-content/index.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,7 @@ export const handler = documentEventHandler<ContentDocument>(
560560
"Content-Type": "application/json",
561561
Accept: "application/json",
562562
"builder-session-token": awsSessionToken,
563+
Cookie: `builder-session-token=${awsSessionToken}`,
563564
};
564565

565566
const existingSyndication = await client

‎scripts/run-syndicate-post.mjs‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,7 @@ async function run() {
318318
"Content-Type": "application/json",
319319
Accept: "application/json",
320320
"builder-session-token": awsSessionToken,
321+
Cookie: `builder-session-token=${awsSessionToken}`,
321322
};
322323

323324
try {
@@ -457,7 +458,11 @@ async function run() {
457458
// --- LINK SYNDICATION REFERENCES ON PARENT ---
458459
try {
459460
const platforms = ["devto", "hashnode", ...(shouldSyndicateAws ? ["awsbuilder"] : [])];
460-
const expectedRefs = platforms.map((p) => `syndication.${doc._id}.${p}`);
461+
const candidateRefs = platforms.map((p) => `syndication.${doc._id}.${p}`);
462+
const existingSynDocs = await Promise.all(
463+
candidateRefs.map((ref) => client.getDocument(ref).catch(() => null))
464+
);
465+
const expectedRefs = candidateRefs.filter((_, idx) => Boolean(existingSynDocs[idx]));
461466
const latestDoc = await client.getDocument(doc._id);
462467
const existingRefs = (latestDoc?.syndications || []).map((s) => s._ref);
463468

0 commit comments

Comments
 (0)