Skip to content

Commit 8e0dc5b

Browse files
flopez7portuu3
authored andcommitted
feat: support multiple event types in webhook status query (#3234)
1 parent 3a001e3 commit 8e0dc5b

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

packages/apps/job-launcher/server/src/modules/cron-job/cron-job.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ export class CronJobService {
342342
try {
343343
const webhookEntities = await this.webhookRepository.findByStatusAndType(
344344
WebhookStatus.PENDING,
345-
EventType.ESCROW_CREATED,
345+
[EventType.ESCROW_CREATED, EventType.ESCROW_CANCELED],
346346
);
347347

348348
for (const webhookEntity of webhookEntities) {

packages/apps/job-launcher/server/src/modules/webhook/webhook.repository.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Injectable, Logger } from '@nestjs/common';
22

33
import { BaseRepository } from '../../database/base.repository';
4-
import { DataSource, LessThanOrEqual } from 'typeorm';
4+
import { DataSource, In, LessThanOrEqual } from 'typeorm';
55
import { ServerConfigService } from '../../common/config/server-config.service';
66
import { EventType, WebhookStatus } from '../../common/enums/webhook';
77
import { WebhookEntity } from './webhook.entity';
@@ -17,12 +17,13 @@ export class WebhookRepository extends BaseRepository<WebhookEntity> {
1717
}
1818
public findByStatusAndType(
1919
status: WebhookStatus,
20-
type: EventType,
20+
type: EventType | EventType[],
2121
): Promise<WebhookEntity[]> {
22+
const typeClause = !Array.isArray(type) ? [type] : type;
2223
return this.find({
2324
where: {
2425
status: status,
25-
eventType: type,
26+
eventType: In(typeClause),
2627
retriesCount: LessThanOrEqual(this.serverConfigService.maxRetryCount),
2728
waitUntil: LessThanOrEqual(new Date()),
2829
},

0 commit comments

Comments
 (0)