Skip to content

Commit 37f99ae

Browse files
authored
Merge pull request #219 from vernu/dev
fix failing tests
2 parents 677b2dd + 1a5e095 commit 37f99ae

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

api/src/webhook/webhook.service.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { HttpException, HttpStatus, Injectable } from '@nestjs/common'
2-
import { Model } from 'mongoose'
2+
import { Model, Types } from 'mongoose'
33
import {
44
WebhookSubscription,
55
WebhookSubscriptionDocument,
@@ -418,7 +418,9 @@ export class WebhookService {
418418
return
419419
}
420420

421-
const webhookSubscriptionId = webhookNotification.webhookSubscription
421+
const wsRef = webhookNotification.webhookSubscription
422+
const webhookSubscriptionId =
423+
wsRef instanceof Types.ObjectId ? wsRef : wsRef._id!
422424
const webhookSubscription = await this.webhookSubscriptionModel.findById(
423425
webhookSubscriptionId,
424426
)
@@ -478,7 +480,7 @@ export class WebhookService {
478480
await webhookNotification.save()
479481

480482
await this.webhookSubscriptionModel.updateOne(
481-
{ _id: webhookSubscriptionId },
483+
{ _id: webhookSubscription._id },
482484
{
483485
$inc: { successfulDeliveryCount: 1, deliveryAttemptCount: 1 },
484486
$set: { lastDeliverySuccessAt: now },
@@ -528,7 +530,7 @@ export class WebhookService {
528530
await webhookNotification.save()
529531

530532
await this.webhookSubscriptionModel.updateOne(
531-
{ _id: webhookSubscriptionId },
533+
{ _id: webhookSubscription._id },
532534
{
533535
$inc: { deliveryFailureCount: 1, deliveryAttemptCount: 1 },
534536
$set: { lastDeliveryFailureAt: now },

0 commit comments

Comments
 (0)