mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-22 15:50:32 +00:00
refactor(nestjs): Implement users module
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
import { JOB_REF, Process, Processor } from '@nestjs/bull';
|
||||
import { Job } from 'bull';
|
||||
import { Inject, Scope } from '@nestjs/common';
|
||||
import { REQUEST } from '@nestjs/core';
|
||||
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 {
|
||||
constructor(
|
||||
private readonly sendInviteUsersMailService: SendInviteUsersMailMessage,
|
||||
@Inject(REQUEST) private readonly request: Request,
|
||||
@Inject(JOB_REF)
|
||||
private readonly jobRef: Job<SendInviteUserMailJobPayload>,
|
||||
private readonly clsService: ClsService,
|
||||
) {}
|
||||
|
||||
@Process(SendInviteUserMailJob)
|
||||
async handleSendInviteMail() {
|
||||
const { fromUser, invite, organizationId, userId } = this.jobRef.data;
|
||||
|
||||
this.clsService.set('organizationId', organizationId);
|
||||
this.clsService.set('userId', userId);
|
||||
|
||||
try {
|
||||
await this.sendInviteUsersMailService.sendInviteMail(fromUser, invite);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user