Updating wait list to expect dutch emails as well
This commit is contained in:
parent
cc37cfd19f
commit
dbca10c63e
2 changed files with 21 additions and 3 deletions
|
|
@ -123,4 +123,15 @@ export class NtfyProvider implements OnApplicationBootstrap {
|
|||
}),
|
||||
)
|
||||
}
|
||||
|
||||
async sendWaitListEmailReceivedNotification(subject: string) {
|
||||
await this.publishQueue.add(
|
||||
...NtfyProvider.defaultJob({
|
||||
title: 'Wait listed reservation available',
|
||||
message: `${subject}`,
|
||||
tags: [MessageTags.badminton, MessageTags.hourglass],
|
||||
priority: MessagePriority.low,
|
||||
}),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import { InjectQueue, Process, Processor } from '@nestjs/bull'
|
||||
import { Inject } from '@nestjs/common'
|
||||
import { Job, Queue } from 'bull'
|
||||
import { NtfyProvider } from 'src/ntfy/provider'
|
||||
|
||||
import dayjs from '../common/dayjs'
|
||||
import { EMAILS_QUEUE_NAME } from '../email/config'
|
||||
|
|
@ -12,7 +13,7 @@ import { ReservationsService } from '../reservations/service'
|
|||
import { WaitingListDetails } from './types'
|
||||
|
||||
const EMAIL_SUBJECT_REGEX = new RegExp(
|
||||
/^personal waitinglist reservation free at/i,
|
||||
/^(?:personal waitinglist reservation free at|persoonlijke wachtlijst reservering vrij om)/i,
|
||||
)
|
||||
const EMAIL_ADDRESS = 'Squash City <no-reply@i-reservations.nl>'
|
||||
const EMAIL_DATE_REGEX = new RegExp(
|
||||
|
|
@ -35,6 +36,9 @@ export class WaitingListService {
|
|||
@Inject(EmailProvider)
|
||||
private readonly emailProvider: EmailProvider,
|
||||
|
||||
@Inject(NtfyProvider)
|
||||
private readonly ntfyProvider: NtfyProvider,
|
||||
|
||||
@Inject(LoggerService)
|
||||
private readonly loggerService: LoggerService,
|
||||
) {}
|
||||
|
|
@ -50,8 +54,11 @@ export class WaitingListService {
|
|||
|
||||
if (!this.isRelevantEmail) return
|
||||
|
||||
await this.emailProvider.readEmails([email])
|
||||
await this.handleWaitingListEmail(email)
|
||||
await Promise.all([
|
||||
this.ntfyProvider.sendWaitListEmailReceivedNotification(email.subject),
|
||||
this.emailProvider.readEmails([email]),
|
||||
this.handleWaitingListEmail(email),
|
||||
])
|
||||
}
|
||||
|
||||
private async handleWaitingListEmail(email: Email) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue