in lib/recipes-data/src/lib/takedown.ts [130:180]
export async function removeAllRecipesForArticle({
canonicalArticleId,
staticBucketName,
fastlyApiKey,
contentPrefix,
outgoingEventBus,
}: {
canonicalArticleId: string;
staticBucketName: string;
fastlyApiKey: string;
contentPrefix: string;
outgoingEventBus: string;
}): Promise<number> {
const removedEntries =
await removeAllRecipeIndexEntriesForArticle(canonicalArticleId);
console.log(
`Taken down article ${canonicalArticleId} had ${removedEntries.length} recipes in it which will also be removed`,
);
await Promise.all(
removedEntries.map((recep) =>
removeRecipeContent({
recipeSHA: recep.checksum,
staticBucketName: staticBucketName,
fastlyApiKey,
contentPrefix,
purgeType: 'hard',
}),
),
);
try {
await announceNewRecipe([], removedEntries, outgoingEventBus);
} catch (e) {
const err = e as Error;
console.error(`Unable to announce takedowns: ${err.toString()}`);
}
try {
await Promise.all(
removedEntries.map((recep) =>
sendTelemetryEvent('TakenDown', recep.recipeUID, ''),
),
);
} catch (err) {
console.error(
`ERROR [${canonicalArticleId}] - unable to send telemetry: `,
err,
);
}
return removedEntries.length;
}