From 50c1366704e7df8f75b20666b3e1e59e500a0128 Mon Sep 17 00:00:00 2001 From: Matthieu Sieben Date: Tue, 5 Dec 2023 17:51:04 +0100 Subject: [PATCH] fix(bsky): cf image invalidator not taken into account when bunny used (#1823) --- services/bsky/api.js | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/services/bsky/api.js b/services/bsky/api.js index 2e78d3bafec..cf4e59afb37 100644 --- a/services/bsky/api.js +++ b/services/bsky/api.js @@ -79,32 +79,32 @@ const main = async () => { const signingKey = await Secp256k1Keypair.import(env.serviceSigningKey) - // configure zero, one, or both image invalidators - let imgInvalidator - const bunnyInvalidator = env.bunnyAccessKey - ? new BunnyInvalidator({ + // configure zero, one, or more image invalidators + const imgInvalidators = [] + + if (env.bunnyAccessKey) { + imgInvalidators.push( + new BunnyInvalidator({ accessKey: env.bunnyAccessKey, urlPrefix: cfg.imgUriEndpoint, - }) - : undefined - const cfInvalidator = env.cfDistributionId - ? new CloudfrontInvalidator({ + }), + ) + } + + if (env.cfDistributionId) { + imgInvalidators.push( + new CloudfrontInvalidator({ distributionId: env.cfDistributionId, pathPrefix: cfg.imgUriEndpoint && new URL(cfg.imgUriEndpoint).pathname, - }) - : undefined - - if (bunnyInvalidator && imgInvalidator) { - imgInvalidator = new MultiImageInvalidator([ - bunnyInvalidator, - imgInvalidator, - ]) - } else if (bunnyInvalidator) { - imgInvalidator = bunnyInvalidator - } else if (cfInvalidator) { - imgInvalidator = cfInvalidator + }), + ) } + const imgInvalidator = + imgInvalidators.length > 1 + ? new MultiImageInvalidator(imgInvalidators) + : imgInvalidators[0] + const algos = env.feedPublisherDid ? makeAlgos(env.feedPublisherDid) : {} const bsky = BskyAppView.create({ db,