feat: send mail notifications of payment

This commit is contained in:
Ahmed Bouhuolia
2023-12-24 21:51:23 +02:00
parent b6d99b1d4b
commit 13c6e7a62d
5 changed files with 215 additions and 6 deletions

View File

@@ -0,0 +1,35 @@
import Container, { Service } from 'typedi';
import events from '@/subscribers/events';
import { SendPaymentReceiveMailNotification } from './PaymentReceiveMailNotification';
@Service()
export class PaymentReceiveMailNotificationJob {
/**
* Constructor method.
*/
constructor(agenda) {
agenda.define(
'payment-receive-mail-send',
{ priority: 'high', concurrency: 2 },
this.handler
);
}
/**
* Triggers sending payment notification via mail.
*/
private handler = async (job, done: Function) => {
const { tenantId, paymentReceiveId, messageDTO } = job.attrs.data;
const paymentMail = Container.get(SendPaymentReceiveMailNotification);
console.log(tenantId, paymentReceiveId, messageDTO);
try {
await paymentMail.sendMail(tenantId, paymentReceiveId, messageDTO);
done();
} catch (error) {
console.log(error);
done(error);
}
};
}