From 338fb665bced8742aec18f0f13a4f3ab409575f2 Mon Sep 17 00:00:00 2001 From: isra el Date: Thu, 5 Mar 2026 11:54:20 +0300 Subject: [PATCH] fix(api): fix webhooksubscription save issue --- api/src/webhook/webhook.service.ts | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/api/src/webhook/webhook.service.ts b/api/src/webhook/webhook.service.ts index be28e56..7c7aeee 100644 --- a/api/src/webhook/webhook.service.ts +++ b/api/src/webhook/webhook.service.ts @@ -477,10 +477,13 @@ export class WebhookService { webhookNotification.responseBody = responseBody await webhookNotification.save() - webhookSubscription.successfulDeliveryCount += 1 - webhookSubscription.lastDeliverySuccessAt = now - webhookSubscription.deliveryAttemptCount += 1 - await webhookSubscription.save() + await this.webhookSubscriptionModel.updateOne( + { _id: webhookSubscriptionId }, + { + $inc: { successfulDeliveryCount: 1, deliveryAttemptCount: 1 }, + $set: { lastDeliverySuccessAt: now }, + }, + ) } catch (e) { // Classify error type if (e.response?.status) { @@ -524,10 +527,13 @@ export class WebhookService { await webhookNotification.save() - webhookSubscription.deliveryFailureCount += 1 - webhookSubscription.lastDeliveryFailureAt = now - webhookSubscription.deliveryAttemptCount += 1 - await webhookSubscription.save() + await this.webhookSubscriptionModel.updateOne( + { _id: webhookSubscriptionId }, + { + $inc: { deliveryFailureCount: 1, deliveryAttemptCount: 1 }, + $set: { lastDeliveryFailureAt: now }, + }, + ) console.log( `Failed to deliver webhook notification: ID ${webhookNotification._id}, status code: ${httpStatusCode}, error type: ${errorType}, message: ${e.message}`,