mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 21:00:31 +00:00
fix: sending mail jobs
This commit is contained in:
@@ -99,7 +99,8 @@ export class SaleInvoicesController {
|
||||
return this.saleInvoiceApplication.createSaleInvoice(saleInvoiceDTO);
|
||||
}
|
||||
|
||||
@Put(':id/mail')
|
||||
@Post(':id/mail')
|
||||
@HttpCode(200)
|
||||
@ApiOperation({ summary: 'Send the sale invoice mail.' })
|
||||
@ApiResponse({
|
||||
status: 200,
|
||||
|
||||
@@ -33,7 +33,7 @@ export class SendSaleInvoiceMail {
|
||||
private readonly tenancyContect: TenancyContext,
|
||||
|
||||
@InjectQueue(SendSaleInvoiceQueue) private readonly sendInvoiceQueue: Queue,
|
||||
) {}
|
||||
) { }
|
||||
|
||||
/**
|
||||
* Sends the invoice mail of the given sale invoice.
|
||||
@@ -132,7 +132,13 @@ export class SendSaleInvoiceMail {
|
||||
events.saleInvoice.onMailSend,
|
||||
eventPayload,
|
||||
);
|
||||
await this.mailTransporter.send(mail);
|
||||
|
||||
try {
|
||||
await this.mailTransporter.send(mail);
|
||||
} catch (error) {
|
||||
console.error('Failed to send invoice mail:', error);
|
||||
throw error;
|
||||
}
|
||||
|
||||
// Triggers the event `onSaleInvoiceSend`.
|
||||
await this.eventEmitter.emitAsync(
|
||||
|
||||
@@ -18,9 +18,10 @@ export class SendSaleInvoiceMailProcessor {
|
||||
@Inject(JOB_REF)
|
||||
private readonly jobRef: Job<SendSaleInvoiceMailJobPayload>,
|
||||
private readonly clsService: ClsService,
|
||||
) {}
|
||||
) { }
|
||||
|
||||
@Process(SendSaleInvoiceMailJob)
|
||||
@UseCls()
|
||||
async handleSendInvoice() {
|
||||
const { messageOptions, saleInvoiceId, organizationId, userId } =
|
||||
this.jobRef.data;
|
||||
@@ -31,7 +32,8 @@ export class SendSaleInvoiceMailProcessor {
|
||||
try {
|
||||
await this.sendSaleInvoiceMail.sendMail(saleInvoiceId, messageOptions);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
console.error('Failed to process invoice mail job:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user