mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-20 14:50:32 +00:00
feat(nestjs): migrate to NestJS
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
import { Process, Processor } from '@nestjs/bull';
|
||||
import { Job } from 'bull';
|
||||
import { SendSaleReceiptMailQueue } from '../constants';
|
||||
import { SaleReceiptMailNotification } from '../commands/SaleReceiptMailNotification';
|
||||
import { SaleReceiptSendMailPayload } from '../types/SaleReceipts.types';
|
||||
import { ClsService } from 'nestjs-cls';
|
||||
|
||||
@Processor(SendSaleReceiptMailQueue)
|
||||
export class SendSaleReceiptMailProcess {
|
||||
constructor(
|
||||
private readonly saleReceiptMailNotification: SaleReceiptMailNotification,
|
||||
private readonly clsService: ClsService,
|
||||
) {}
|
||||
|
||||
@Process(SendSaleReceiptMailQueue)
|
||||
async handleSendMailJob(job: Job<SaleReceiptSendMailPayload>) {
|
||||
const { messageOpts, saleReceiptId, organizationId, userId } = job.data;
|
||||
|
||||
this.clsService.set('organizationId', organizationId);
|
||||
this.clsService.set('userId', userId);
|
||||
|
||||
await this.saleReceiptMailNotification.sendMail(saleReceiptId, messageOpts);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user