mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-25 00:59:50 +00:00
- Add missing BullModule queue registration and BullBoardModule to UsersModule - Add invitingUser to event payloads to track who sent the invite - Fix incorrect global variable in SendInviteUsersMailMessage (__views_dir -> __images_dirname) - Use invitingUser as fromUser instead of invited user in email - Update processors to use BullMQ pattern Fixes issues: 1. Email not sending due to missing queue/processor registration 2. Null variables in email (firstName/lastName) because fromUser was the invited user 3. Image attachment failing due to wrong path
39 lines
1.1 KiB
TypeScript
39 lines
1.1 KiB
TypeScript
import { Processor, WorkerHost } from '@nestjs/bullmq';
|
|
import { Job } from 'bullmq';
|
|
import { Scope } from '@nestjs/common';
|
|
import { ClsService, UseCls } from 'nestjs-cls';
|
|
import {
|
|
SendInviteUserMailJob,
|
|
SendInviteUserMailQueue,
|
|
} from '../Users.constants';
|
|
import { SendInviteUserMailJobPayload } from '../Users.types';
|
|
import { SendInviteUsersMailMessage } from '../commands/SendInviteUsersMailMessage.service';
|
|
|
|
@Processor({
|
|
name: SendInviteUserMailQueue,
|
|
scope: Scope.REQUEST,
|
|
})
|
|
export class SendInviteUserMailProcessor extends WorkerHost {
|
|
constructor(
|
|
private readonly sendInviteUsersMailService: SendInviteUsersMailMessage,
|
|
private readonly clsService: ClsService,
|
|
) {
|
|
super();
|
|
}
|
|
|
|
@UseCls()
|
|
async process(job: Job<SendInviteUserMailJobPayload>) {
|
|
const { fromUser, invite, organizationId, userId } = job.data;
|
|
|
|
this.clsService.set('organizationId', organizationId);
|
|
this.clsService.set('userId', userId);
|
|
|
|
try {
|
|
await this.sendInviteUsersMailService.sendInviteMail(fromUser, invite);
|
|
} catch (error) {
|
|
console.error('Failed to process invite user mail job:', error);
|
|
throw error;
|
|
}
|
|
}
|
|
}
|