Files
twenty/packages/twenty-server/src/modules/calendar/calendar-event-participant-manager/jobs/calendar-event-participant-unmatch-participant.job.ts
bosiraphael d0db3b765f 6255 move services from messaging common module into the correct module and refactor them (#6409)
Closes #6255 

- Move files from `messaging/common` into the correct module
- Remove common module between calendar and messaging
`calendar-messaging-participant-manager`
- Update and fix massaging and calendar participant matching
- Create `MatchParticipantModule`

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
2024-07-27 12:29:02 +02:00

39 lines
1.4 KiB
TypeScript

import { Scope } from '@nestjs/common';
import { Process } from 'src/engine/integrations/message-queue/decorators/process.decorator';
import { Processor } from 'src/engine/integrations/message-queue/decorators/processor.decorator';
import { MessageQueue } from 'src/engine/integrations/message-queue/message-queue.constants';
import { CalendarEventParticipantWorkspaceEntity } from 'src/modules/calendar/common/standard-objects/calendar-event-participant.workspace-entity';
import { MatchParticipantService } from 'src/modules/match-participant/match-participant.service';
export type CalendarEventParticipantUnmatchParticipantJobData = {
workspaceId: string;
email: string;
personId?: string;
workspaceMemberId?: string;
};
@Processor({
queueName: MessageQueue.calendarQueue,
scope: Scope.REQUEST,
})
export class CalendarEventParticipantUnmatchParticipantJob {
constructor(
private readonly matchParticipantService: MatchParticipantService<CalendarEventParticipantWorkspaceEntity>,
) {}
@Process(CalendarEventParticipantUnmatchParticipantJob.name)
async handle(
data: CalendarEventParticipantUnmatchParticipantJobData,
): Promise<void> {
const { email, personId, workspaceMemberId } = data;
await this.matchParticipantService.unmatchParticipants(
email,
'calendarEventParticipant',
personId,
workspaceMemberId,
);
}
}