|
1 | 1 | import { HttpException, HttpStatus, Injectable } from '@nestjs/common' |
2 | | -import { Model } from 'mongoose' |
| 2 | +import { Model, Types } from 'mongoose' |
3 | 3 | import { |
4 | 4 | WebhookSubscription, |
5 | 5 | WebhookSubscriptionDocument, |
@@ -418,7 +418,9 @@ export class WebhookService { |
418 | 418 | return |
419 | 419 | } |
420 | 420 |
|
421 | | - const webhookSubscriptionId = webhookNotification.webhookSubscription |
| 421 | + const wsRef = webhookNotification.webhookSubscription |
| 422 | + const webhookSubscriptionId = |
| 423 | + wsRef instanceof Types.ObjectId ? wsRef : wsRef._id! |
422 | 424 | const webhookSubscription = await this.webhookSubscriptionModel.findById( |
423 | 425 | webhookSubscriptionId, |
424 | 426 | ) |
@@ -478,7 +480,7 @@ export class WebhookService { |
478 | 480 | await webhookNotification.save() |
479 | 481 |
|
480 | 482 | await this.webhookSubscriptionModel.updateOne( |
481 | | - { _id: webhookSubscriptionId }, |
| 483 | + { _id: webhookSubscription._id }, |
482 | 484 | { |
483 | 485 | $inc: { successfulDeliveryCount: 1, deliveryAttemptCount: 1 }, |
484 | 486 | $set: { lastDeliverySuccessAt: now }, |
@@ -528,7 +530,7 @@ export class WebhookService { |
528 | 530 | await webhookNotification.save() |
529 | 531 |
|
530 | 532 | await this.webhookSubscriptionModel.updateOne( |
531 | | - { _id: webhookSubscriptionId }, |
| 533 | + { _id: webhookSubscription._id }, |
532 | 534 | { |
533 | 535 | $inc: { deliveryFailureCount: 1, deliveryAttemptCount: 1 }, |
534 | 536 | $set: { lastDeliveryFailureAt: now }, |
|
0 commit comments