Refactor calendar to use new sync statuses and stages (#6141)

- Refactor calendar modules and some messaging modules to better
organize them by business rules and decouple them
- Work toward a common architecture for the different calendar providers
by introducing interfaces for the drivers
- Modify cron job to use the new sync statuses and stages
This commit is contained in:
bosiraphael
2024-07-08 17:01:06 +02:00
committed by GitHub
parent 1c3ea9b106
commit f458322303
69 changed files with 1300 additions and 884 deletions

View File

@ -28,14 +28,14 @@ import { InjectWorkspaceRepository } from 'src/engine/twenty-orm/decorators/inje
import { WorkspaceRepository } from 'src/engine/twenty-orm/repository/workspace.repository';
import { WorkspaceDataSource } from 'src/engine/twenty-orm/datasource/workspace.datasource';
import { InjectWorkspaceDatasource } from 'src/engine/twenty-orm/decorators/inject-workspace-datasource.decorator';
import {
CalendarEventsImportJob,
CalendarEventsImportJobData,
} from 'src/modules/calendar/calendar-event-import-manager/jobs/calendar-events-import.job';
import {
CalendarChannelWorkspaceEntity,
CalendarChannelVisibility,
} from 'src/modules/calendar/common/standard-objects/calendar-channel.workspace-entity';
import {
CalendarEventsImportJobData,
CalendarEventListFetchJob,
} from 'src/modules/calendar/calendar-event-import-manager/jobs/calendar-event-list-fetch.job';
@Injectable()
export class GoogleAPIsService {
@ -167,13 +167,21 @@ export class GoogleAPIsService {
}
if (isCalendarEnabled) {
await this.calendarQueueService.add<CalendarEventsImportJobData>(
CalendarEventsImportJob.name,
{
workspaceId,
const calendarChannels = await this.calendarChannelRepository.find({
where: {
connectedAccountId: newOrExistingConnectedAccountId,
},
);
});
for (const calendarChannel of calendarChannels) {
await this.calendarQueueService.add<CalendarEventsImportJobData>(
CalendarEventListFetchJob.name,
{
calendarChannelId: calendarChannel.id,
workspaceId,
},
);
}
}
}
}