File tree Expand file tree Collapse file tree
apps/sanity/functions/syndicate-content Expand file tree Collapse file tree Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments