feat(server): change estimate and receipts status once delivering mail

This commit is contained in:
Ahmed Bouhuolia
2024-01-25 21:52:07 +02:00
parent 9d4e7cec9e
commit 760dbc6cfc
14 changed files with 171 additions and 13 deletions

View File

@@ -2,6 +2,7 @@ import { Inject, Service } from 'typedi';
import {
PaymentReceiveMailOpts,
PaymentReceiveMailOptsDTO,
PaymentReceiveMailPresendEvent,
SendInvoiceMailDTO,
} from '@/interfaces';
import Mail from '@/lib/Mail';
@@ -13,6 +14,8 @@ import {
import { GetPaymentReceive } from './GetPaymentReceive';
import { ContactMailNotification } from '@/services/MailNotification/ContactMailNotification';
import { parseAndValidateMailOptions } from '@/services/MailNotification/utils';
import { EventPublisher } from '@/lib/EventPublisher/EventPublisher';
import events from '@/subscribers/events';
@Service()
export class SendPaymentReceiveMailNotification {
@@ -28,6 +31,9 @@ export class SendPaymentReceiveMailNotification {
@Inject('agenda')
private agenda: any;
@Inject()
private eventPublisher: EventPublisher;
/**
* Sends the mail of the given payment receive.
* @param {number} tenantId
@@ -46,6 +52,13 @@ export class SendPaymentReceiveMailNotification {
messageDTO,
};
await this.agenda.now('payment-receive-mail-send', payload);
// Triggers `onPaymentReceivePreMailSend` event.
await this.eventPublisher.emitAsync(events.paymentReceive.onPreMailSend, {
tenantId,
paymentReceiveId,
messageOptions: messageDTO,
} as PaymentReceiveMailPresendEvent);
}
/**