fix: sending mail jobs

This commit is contained in:
Ahmed Bouhuolia
2025-12-05 00:07:26 +02:00
parent 32d74b0413
commit c3dc26a1e4
11 changed files with 100 additions and 31 deletions

View File

@@ -1,12 +1,11 @@
import { JOB_REF, Process, Processor } from '@nestjs/bull';
import { Job } from 'bull';
import { Inject, Scope } from '@nestjs/common';
import { ClsService, UseCls } from 'nestjs-cls';
import {
SEND_PAYMENT_RECEIVED_MAIL_JOB,
SEND_PAYMENT_RECEIVED_MAIL_QUEUE,
} from '../constants';
import { Inject, Scope } from '@nestjs/common';
import { REQUEST } from '@nestjs/core';
import { ClsService } from 'nestjs-cls';
import { SendPaymentReceiveMailNotification } from '../commands/PaymentReceivedMailNotification';
import { SendPaymentReceivedMailPayload } from '../types/PaymentReceived.types';
@@ -21,9 +20,10 @@ export class SendPaymentReceivedMailProcessor {
@Inject(JOB_REF)
private readonly jobRef: Job<SendPaymentReceivedMailPayload>,
) {}
) { }
@Process(SEND_PAYMENT_RECEIVED_MAIL_JOB)
@UseCls()
async handleSendMail() {
const { messageOptions, paymentReceivedId, organizationId, userId } =
this.jobRef.data;
@@ -37,7 +37,8 @@ export class SendPaymentReceivedMailProcessor {
messageOptions,
);
} catch (error) {
console.log(error);
console.error('Failed to process payment received mail job:', error);
throw error;
}
}
}