mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 13:20:31 +00:00
31 lines
947 B
TypeScript
31 lines
947 B
TypeScript
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);
|
|
}
|
|
}
|
|
}
|