## Context JobsModule is hard to maintain because we provide all the jobs there, including their dependencies. This PR aims to split jobs in dedicated modules.
42 lines
1.3 KiB
TypeScript
42 lines
1.3 KiB
TypeScript
import { Injectable } from '@nestjs/common';
|
|
|
|
import { MessageQueueJob } from 'src/engine/integrations/message-queue/interfaces/message-queue-job.interface';
|
|
|
|
import { CalendarEventParticipantService } from 'src/modules/calendar/services/calendar-event-participant/calendar-event-participant.service';
|
|
import { MessageParticipantService } from 'src/modules/messaging/services/message-participant/message-participant.service';
|
|
|
|
export type UnmatchParticipantJobData = {
|
|
workspaceId: string;
|
|
email: string;
|
|
personId?: string;
|
|
workspaceMemberId?: string;
|
|
};
|
|
|
|
@Injectable()
|
|
export class UnmatchParticipantJob
|
|
implements MessageQueueJob<UnmatchParticipantJobData>
|
|
{
|
|
constructor(
|
|
private readonly messageParticipantService: MessageParticipantService,
|
|
private readonly calendarEventParticipantService: CalendarEventParticipantService,
|
|
) {}
|
|
|
|
async handle(data: UnmatchParticipantJobData): Promise<void> {
|
|
const { workspaceId, email, personId, workspaceMemberId } = data;
|
|
|
|
await this.messageParticipantService.unmatchMessageParticipants(
|
|
workspaceId,
|
|
email,
|
|
personId,
|
|
workspaceMemberId,
|
|
);
|
|
|
|
await this.calendarEventParticipantService.unmatchCalendarEventParticipants(
|
|
workspaceId,
|
|
email,
|
|
personId,
|
|
workspaceMemberId,
|
|
);
|
|
}
|
|
}
|