mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 21:30:31 +00:00
refactor: nestjs
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
import { JOB_REF, Process, Processor } from '@nestjs/bull';
|
||||
import { Job } from 'bull';
|
||||
import { SendSaleInvoiceMailJob, SendSaleInvoiceQueue } from '../constants';
|
||||
import { SendSaleInvoiceMail } from '../commands/SendSaleInvoiceMail';
|
||||
import { Inject, Scope } from '@nestjs/common';
|
||||
import { REQUEST } from '@nestjs/core';
|
||||
import { UseCls } from 'nestjs-cls';
|
||||
|
||||
@Processor({
|
||||
name: SendSaleInvoiceQueue,
|
||||
scope: Scope.REQUEST,
|
||||
})
|
||||
export class SendSaleInvoiceMailProcessor {
|
||||
constructor(
|
||||
private readonly sendSaleInvoiceMail: SendSaleInvoiceMail,
|
||||
@Inject(REQUEST) private readonly request: Request,
|
||||
@Inject(JOB_REF) private readonly jobRef: Job,
|
||||
) {}
|
||||
|
||||
@Process(SendSaleInvoiceMailJob)
|
||||
async handleSendInvoice() {
|
||||
const { messageOptions, saleInvoiceId } = this.jobRef.data;
|
||||
|
||||
try {
|
||||
await this.sendSaleInvoiceMail.sendMail(saleInvoiceId, messageOptions);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user