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>
This commit is contained in:
bosiraphael
2024-07-27 12:29:02 +02:00
committed by GitHub
parent 3060eb4e1e
commit d0db3b765f
42 changed files with 398 additions and 540 deletions

View File

@ -4,7 +4,8 @@ import { WorkspaceService } from 'src/engine/core-modules/workspace/services/wor
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 { CalendarEventParticipantService } from 'src/modules/calendar/calendar-event-participant-manager/services/calendar-event-participant.service';
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 CalendarEventParticipantMatchParticipantJobData = {
workspaceId: string;
@ -19,8 +20,8 @@ export type CalendarEventParticipantMatchParticipantJobData = {
})
export class CalendarEventParticipantMatchParticipantJob {
constructor(
private readonly calendarEventParticipantService: CalendarEventParticipantService,
private readonly workspaceService: WorkspaceService,
private readonly matchParticipantService: MatchParticipantService<CalendarEventParticipantWorkspaceEntity>,
) {}
@Process(CalendarEventParticipantMatchParticipantJob.name)
@ -33,9 +34,9 @@ export class CalendarEventParticipantMatchParticipantJob {
return;
}
await this.calendarEventParticipantService.matchCalendarEventParticipants(
workspaceId,
await this.matchParticipantService.matchParticipantsAfterPersonOrWorkspaceMemberCreation(
email,
'calendarEventParticipant',
personId,
workspaceMemberId,
);

View File

@ -1,9 +1,10 @@
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 { Process } from 'src/engine/integrations/message-queue/decorators/process.decorator';
import { CalendarEventParticipantService } from 'src/modules/calendar/calendar-event-participant-manager/services/calendar-event-participant.service';
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;
@ -18,18 +19,18 @@ export type CalendarEventParticipantUnmatchParticipantJobData = {
})
export class CalendarEventParticipantUnmatchParticipantJob {
constructor(
private readonly calendarEventParticipantService: CalendarEventParticipantService,
private readonly matchParticipantService: MatchParticipantService<CalendarEventParticipantWorkspaceEntity>,
) {}
@Process(CalendarEventParticipantUnmatchParticipantJob.name)
async handle(
data: CalendarEventParticipantUnmatchParticipantJobData,
): Promise<void> {
const { workspaceId, email, personId, workspaceMemberId } = data;
const { email, personId, workspaceMemberId } = data;
await this.calendarEventParticipantService.unmatchCalendarEventParticipants(
workspaceId,
await this.matchParticipantService.unmatchParticipants(
email,
'calendarEventParticipant',
personId,
workspaceMemberId,
);