Files
twenty/packages/twenty-server/src/modules/calendar-messaging-participant/jobs/unmatch-participant.job.ts
Weiko 8074aae449 Split job modules (#5318)
## 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.
2024-05-07 14:08:20 +02:00

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,
);
}
}