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>
39 lines
1.4 KiB
TypeScript
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,
|
|
);
|
|
}
|
|
}
|