From d330134c6b376e854859c0fa6179aa7bed95b352 Mon Sep 17 00:00:00 2001 From: nicktrn <55853254+nicktrn@users.noreply.github.com> Date: Thu, 7 Dec 2023 09:09:36 +0000 Subject: [PATCH] Remove redundant batch param --- .../app/services/sources/deliverWebhookRequest.server.ts | 7 ++++--- apps/webapp/app/services/worker.server.ts | 6 +++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/apps/webapp/app/services/sources/deliverWebhookRequest.server.ts b/apps/webapp/app/services/sources/deliverWebhookRequest.server.ts index 5d21ec454..b65a9c1ff 100644 --- a/apps/webapp/app/services/sources/deliverWebhookRequest.server.ts +++ b/apps/webapp/app/services/sources/deliverWebhookRequest.server.ts @@ -11,7 +11,7 @@ export class DeliverWebhookRequestService { this.#prismaClient = prismaClient; } - public async call(webhookEnvironmentId: string, requestDeliveryIds: string[], batched = false) { + public async call(webhookEnvironmentId: string, requestDeliveryIds: string[]) { const webhookEnvironment = await this.#prismaClient.webhookEnvironment.findUniqueOrThrow({ where: { id: webhookEnvironmentId, @@ -31,6 +31,7 @@ export class DeliverWebhookRequestService { }, }, }, + deliveryBatcher: true, environment: { include: { organization: true, @@ -58,7 +59,7 @@ export class DeliverWebhookRequestService { throw new Error(`No request deliveries found, expected ${requestDeliveryIds.length} total.`); } - if (!batched && requestDeliveries.length > 1) { + if (requestDeliveries.length > 1 && !webhookEnvironment.deliveryBatcher) { throw new Error( `Batching is disabled. Will not handle multiple deliveries. Requested ${requestDeliveryIds.length} total.` ); @@ -96,7 +97,7 @@ export class DeliverWebhookRequestService { secret: secret.secret, params: webhookEnvironment.webhook.params, requests, - batched, + batched: !!webhookEnvironment.deliveryBatcher, }); const deliveredAt = new Date(); diff --git a/apps/webapp/app/services/worker.server.ts b/apps/webapp/app/services/worker.server.ts index 1a1b7f455..fe0a2ebf2 100644 --- a/apps/webapp/app/services/worker.server.ts +++ b/apps/webapp/app/services/worker.server.ts @@ -255,7 +255,7 @@ function getWorkerQueue() { throw new Error("Job key is required for batch jobs."); } - const batcherId = job.key.split(":")[0] + const batcherId = job.key.split(":")[0]; const service = new DispatchBatcherService(); @@ -353,7 +353,7 @@ function getWorkerQueue() { throw new Error("Job key is required for batch jobs."); } - const batcherId = job.key.split(":")[0] + const batcherId = job.key.split(":")[0]; const service = new WebhookDeliveryBatcherService(); @@ -367,7 +367,7 @@ function getWorkerQueue() { handler: async (payload, job) => { const service = new DeliverWebhookRequestService(); - await service.call(payload.webhookEnvironmentId, payload.requestDeliveryIds, true); + await service.call(payload.webhookEnvironmentId, payload.requestDeliveryIds); }, }, deliverWebhookRequest: {