Skip to content

The open alternative to Salesforce, designed for AI.

Fix cron module structure (#4933)

Weikof4fda221b720
diff --git a/packages/twenty-server/src/command/command.module.ts b/packages/twenty-server/src/command/command.module.ts
index 406a3023052..fd7e9fd980f 100644
--- a/packages/twenty-server/src/command/command.module.ts
+++ b/packages/twenty-server/src/command/command.module.ts
@@ -1,21 +1,23 @@
import { Module } from '@nestjs/common';
import { DatabaseCommandModule } from 'src/database/commands/database-command.module';
-import { MessagingCommandModule } from 'src/modules/messaging/commands/messaging-command.module';
import { WorkspaceHealthCommandModule } from 'src/engine/workspace-manager/workspace-health/commands/workspace-health-command.module';
import { WorkspaceCleanerModule } from 'src/engine/workspace-manager/workspace-cleaner/workspace-cleaner.module';
-import { WorkspaceCalendarSyncCommandsModule } from 'src/modules/calendar/commands/workspace-calendar-sync-commands.module';
+import { CalendarCronCommandsModule } from 'src/modules/calendar/crons/commands/calendar-cron-commands.module';
import { AppModule } from 'src/app.module';
import { WorkspaceMigrationRunnerCommandsModule } from 'src/engine/workspace-manager/workspace-migration-runner/commands/workspace-sync-metadata-commands.module';
import { WorkspaceSyncMetadataCommandsModule } from 'src/engine/workspace-manager/workspace-sync-metadata/commands/workspace-sync-metadata-commands.module';
+import { MessagingCronCommandsModule } from 'src/modules/messaging/crons/commands/messaging-cron-commands.module';
+import { CalendarCommandsModule } from 'src/modules/calendar/commands/calendar-commands.module';
@Module({
imports: [
AppModule,
WorkspaceSyncMetadataCommandsModule,
DatabaseCommandModule,
- MessagingCommandModule,
- WorkspaceCalendarSyncCommandsModule,
+ MessagingCronCommandsModule,
+ CalendarCronCommandsModule,
+ CalendarCommandsModule,
WorkspaceCleanerModule,
WorkspaceHealthCommandModule,
WorkspaceMigrationRunnerCommandsModule,
diff --git a/packages/twenty-server/src/engine/core-modules/auth/services/google-apis.service.ts b/packages/twenty-server/src/engine/core-modules/auth/services/google-apis.service.ts
index b812c861d5f..9322f6e2fcd 100644
--- a/packages/twenty-server/src/engine/core-modules/auth/services/google-apis.service.ts
+++ b/packages/twenty-server/src/engine/core-modules/auth/services/google-apis.service.ts
@@ -1,43 +1,43 @@
-import { Inject, Injectable } from '@nestjs/common';
+import { Injectable, Inject } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
+import { Repository, EntityManager } from 'typeorm';
import { v4 } from 'uuid';
-import { EntityManager, Repository } from 'typeorm';
-import { DataSourceService } from 'src/engine/metadata-modules/data-source/data-source.service';
import { TypeORMService } from 'src/database/typeorm/typeorm.service';
+import {
+ FeatureFlagEntity,
+ FeatureFlagKeys,
+} from 'src/engine/core-modules/feature-flag/feature-flag.entity';
+import { EnvironmentService } from 'src/engine/integrations/environment/environment.service';
import { MessageQueue } from 'src/engine/integrations/message-queue/message-queue.constants';
import { MessageQueueService } from 'src/engine/integrations/message-queue/services/message-queue.service';
+import { DataSourceService } from 'src/engine/metadata-modules/data-source/data-source.service';
+import { InjectObjectMetadataRepository } from 'src/engine/object-metadata-repository/object-metadata-repository.decorator';
import {
- GoogleCalendarSyncJob,
GoogleCalendarSyncJobData,
+ GoogleCalendarSyncJob,
} from 'src/modules/calendar/jobs/google-calendar-sync.job';
-import { EnvironmentService } from 'src/engine/integrations/environment/environment.service';
-import {
- FeatureFlagEntity,
- FeatureFlagKeys,
-} from 'src/engine/core-modules/feature-flag/feature-flag.entity';
+import { CalendarChannelRepository } from 'src/modules/calendar/repositories/calendar-channel.repository';
import {
- GmailFullSyncV2Job,
- GmailFullSyncV2JobData,
-} from 'src/modules/messaging/jobs/gmail-full-sync-v2.job';
-import { InjectObjectMetadataRepository } from 'src/engine/object-metadata-repository/object-metadata-repository.decorator';
+ CalendarChannelObjectMetadata,
+ CalendarChannelVisibility,
+} from 'src/modules/calendar/standard-objects/calendar-channel.object-metadata';
+import { ConnectedAccountRepository } from 'src/modules/connected-account/repositories/connected-account.repository';
import {
ConnectedAccountObjectMetadata,
ConnectedAccountProvider,
} from 'src/modules/connected-account/standard-objects/connected-account.object-metadata';
-import { ConnectedAccountRepository } from 'src/modules/connected-account/repositories/connected-account.repository';
+import { MessageChannelRepository } from 'src/modules/messaging/repositories/message-channel.repository';
import {
MessageChannelObjectMetadata,
MessageChannelType,
MessageChannelVisibility,
} from 'src/modules/messaging/standard-objects/message-channel.object-metadata';
-import { MessageChannelRepository } from 'src/modules/messaging/repositories/message-channel.repository';
import {
- CalendarChannelObjectMetadata,
- CalendarChannelVisibility,
-} from 'src/modules/calendar/standard-objects/calendar-channel.object-metadata';
-import { CalendarChannelRepository } from 'src/modules/calendar/repositories/calendar-channel.repository';
+ GmailFullSyncJobData,
+ GmailFullSyncJob,
+} from 'src/modules/messaging/jobs/gmail-full-sync.job';
@Injectable()
export class GoogleAPIsService {
@@ -171,8 +171,8 @@ export class GoogleAPIsService {
isCalendarEnabled: boolean,
) {
if (this.environmentService.get('MESSAGING_PROVIDER_GMAIL_ENABLED')) {
- await this.messageQueueService.add<GmailFullSyncV2JobData>(
- GmailFullSyncV2Job.name,
+ await this.messageQueueService.add<GmailFullSyncJobData>(
+ GmailFullSyncJob.name,
{
workspaceId,
connectedAccountId,
diff --git a/packages/twenty-server/src/engine/integrations/message-queue/jobs.module.ts b/packages/twenty-server/src/engine/integrations/message-queue/jobs.module.ts
index 2f9c3e4b2e5..c6105a1fb9f 100644
--- a/packages/twenty-server/src/engine/integrations/message-queue/jobs.module.ts
+++ b/packages/twenty-server/src/engine/integrations/message-queue/jobs.module.ts
@@ -1,58 +1,58 @@
+import { HttpModule } from '@nestjs/axios';
import { Module } from '@nestjs/common';
import { ModuleRef } from '@nestjs/core';
-import { HttpModule } from '@nestjs/axios';
import { TypeOrmModule } from '@nestjs/typeorm';
-import { CallWebhookJobsJob } from 'src/engine/api/graphql/workspace-query-runner/jobs/call-webhook-jobs.job';
-import { CallWebhookJob } from 'src/engine/api/graphql/workspace-query-runner/jobs/call-webhook.job';
-import { WorkspaceDataSourceModule } from 'src/engine/workspace-datasource/workspace-datasource.module';
-import { ObjectMetadataModule } from 'src/engine/metadata-modules/object-metadata/object-metadata.module';
-import { DataSourceModule } from 'src/engine/metadata-modules/data-source/data-source.module';
-import { CleanInactiveWorkspaceJob } from 'src/engine/workspace-manager/workspace-cleaner/crons/clean-inactive-workspace.job';
-import { TypeORMModule } from 'src/database/typeorm/typeorm.module';
-import { EmailSenderJob } from 'src/engine/integrations/email/email-sender.job';
-import { UserModule } from 'src/engine/core-modules/user/user.module';
-import { EnvironmentModule } from 'src/engine/integrations/environment/environment.module';
-import { MatchParticipantJob } from 'src/modules/connected-account/jobs/match-participant.job';
-import { GmailPartialSyncCronJob } from 'src/modules/messaging/jobs/crons/gmail-partial-sync.cron.job';
-import { MessagingCreateCompanyAndContactAfterSyncJob } from 'src/modules/messaging/jobs/messaging-create-company-and-contact-after-sync.job';
-import { AutoCompaniesAndContactsCreationModule } from 'src/modules/connected-account/auto-companies-and-contacts-creation/auto-companies-and-contacts-creation.module';
import { DataSeedDemoWorkspaceModule } from 'src/database/commands/data-seed-demo-workspace/data-seed-demo-workspace.module';
import { DataSeedDemoWorkspaceJob } from 'src/database/commands/data-seed-demo-workspace/jobs/data-seed-demo-workspace.job';
-import { DeleteConnectedAccountAssociatedMessagingDataJob } from 'src/modules/messaging/jobs/delete-connected-account-associated-messaging-data.job';
-import { ThreadCleanerModule } from 'src/modules/messaging/services/thread-cleaner/thread-cleaner.module';
-import { UpdateSubscriptionJob } from 'src/engine/core-modules/billing/jobs/update-subscription.job';
+import { TypeORMModule } from 'src/database/typeorm/typeorm.module';
+import { CallWebhookJobsJob } from 'src/engine/api/graphql/workspace-query-runner/jobs/call-webhook-jobs.job';
+import { CallWebhookJob } from 'src/engine/api/graphql/workspace-query-runner/jobs/call-webhook.job';
+import { RecordPositionBackfillJob } from 'src/engine/api/graphql/workspace-query-runner/jobs/record-position-backfill.job';
+import { SaveEventToDbJob } from 'src/engine/api/graphql/workspace-query-runner/jobs/save-event-to-db.job';
+import { RecordPositionBackfillModule } from 'src/engine/api/graphql/workspace-query-runner/services/record-position-backfill-module';
import { BillingModule } from 'src/engine/core-modules/billing/billing.module';
-import { UserWorkspaceModule } from 'src/engine/core-modules/user-workspace/user-workspace.module';
+import { UpdateSubscriptionJob } from 'src/engine/core-modules/billing/jobs/update-subscription.job';
import { StripeModule } from 'src/engine/core-modules/billing/stripe/stripe.module';
-import { Workspace } from 'src/engine/core-modules/workspace/workspace.entity';
import { FeatureFlagEntity } from 'src/engine/core-modules/feature-flag/feature-flag.entity';
+import { UserWorkspaceModule } from 'src/engine/core-modules/user-workspace/user-workspace.module';
+import { UserModule } from 'src/engine/core-modules/user/user.module';
+import { HandleWorkspaceMemberDeletedJob } from 'src/engine/core-modules/workspace/handle-workspace-member-deleted.job';
+import { Workspace } from 'src/engine/core-modules/workspace/workspace.entity';
+import { EmailSenderJob } from 'src/engine/integrations/email/email-sender.job';
+import { EnvironmentModule } from 'src/engine/integrations/environment/environment.module';
import { DataSourceEntity } from 'src/engine/metadata-modules/data-source/data-source.entity';
+import { DataSourceModule } from 'src/engine/metadata-modules/data-source/data-source.module';
+import { ObjectMetadataModule } from 'src/engine/metadata-modules/object-metadata/object-metadata.module';
+import { ObjectMetadataRepositoryModule } from 'src/engine/object-metadata-repository/object-metadata-repository.module';
+import { WorkspaceDataSourceModule } from 'src/engine/workspace-datasource/workspace-datasource.module';
+import { CleanInactiveWorkspaceJob } from 'src/engine/workspace-manager/workspace-cleaner/crons/clean-inactive-workspace.job';
+import { GoogleCalendarSyncCronJob } from 'src/modules/calendar/crons/jobs/google-calendar-sync.cron.job';
+import { CalendarCreateCompanyAndContactAfterSyncJob } from 'src/modules/calendar/jobs/calendar-create-company-and-contact-after-sync.job';
+import { DeleteConnectedAccountAssociatedCalendarDataJob } from 'src/modules/calendar/jobs/delete-connected-account-associated-calendar-data.job';
import { GoogleCalendarSyncJob } from 'src/modules/calendar/jobs/google-calendar-sync.job';
import { CalendarEventCleanerModule } from 'src/modules/calendar/services/calendar-event-cleaner/calendar-event-cleaner.module';
-import { RecordPositionBackfillJob } from 'src/engine/api/graphql/workspace-query-runner/jobs/record-position-backfill.job';
-import { RecordPositionBackfillModule } from 'src/engine/api/graphql/workspace-query-runner/services/record-position-backfill-module';
+import { CalendarEventParticipantModule } from 'src/modules/calendar/services/calendar-event-participant/calendar-event-participant.module';
import { GoogleCalendarSyncModule } from 'src/modules/calendar/services/google-calendar-sync.module';
+import { AutoCompaniesAndContactsCreationModule } from 'src/modules/connected-account/auto-companies-and-contacts-creation/auto-companies-and-contacts-creation.module';
+import { CreateCompanyAndContactJob } from 'src/modules/connected-account/auto-companies-and-contacts-creation/jobs/create-company-and-contact.job';
+import { MatchParticipantJob } from 'src/modules/connected-account/jobs/match-participant.job';
+import { UnmatchParticipantJob } from 'src/modules/connected-account/jobs/unmatch-participant.job';
import { GoogleAPIRefreshAccessTokenModule } from 'src/modules/connected-account/services/google-api-refresh-access-token/google-api-refresh-access-token.module';
-import { MessageParticipantModule } from 'src/modules/messaging/services/message-participant/message-participant.module';
-import { ObjectMetadataRepositoryModule } from 'src/engine/object-metadata-repository/object-metadata-repository.module';
import { ConnectedAccountObjectMetadata } from 'src/modules/connected-account/standard-objects/connected-account.object-metadata';
-import { MessageChannelObjectMetadata } from 'src/modules/messaging/standard-objects/message-channel.object-metadata';
-import { SaveEventToDbJob } from 'src/engine/api/graphql/workspace-query-runner/jobs/save-event-to-db.job';
-import { CreateCompanyAndContactJob } from 'src/modules/connected-account/auto-companies-and-contacts-creation/jobs/create-company-and-contact.job';
import { EventObjectMetadata } from 'src/modules/event/standard-objects/event.object-metadata';
-import { HandleWorkspaceMemberDeletedJob } from 'src/engine/core-modules/workspace/handle-workspace-member-deleted.job';
-import { GmailFullSynV2Module } from 'src/modules/messaging/services/gmail-full-sync-v2/gmail-full-sync.v2.module';
+import { GmailFetchMessagesFromCacheCronJob } from 'src/modules/messaging/crons/jobs/gmail-fetch-messages-from-cache.cron.job';
+import { GmailPartialSyncCronJob } from 'src/modules/messaging/crons/jobs/gmail-partial-sync.cron.job';
+import { DeleteConnectedAccountAssociatedMessagingDataJob } from 'src/modules/messaging/jobs/delete-connected-account-associated-messaging-data.job';
+import { GmailFullSyncJob } from 'src/modules/messaging/jobs/gmail-full-sync.job';
+import { GmailPartialSyncJob } from 'src/modules/messaging/jobs/gmail-partial-sync.job';
+import { MessagingCreateCompanyAndContactAfterSyncJob } from 'src/modules/messaging/jobs/messaging-create-company-and-contact-after-sync.job';
import { GmailFetchMessageContentFromCacheModule } from 'src/modules/messaging/services/gmail-fetch-message-content-from-cache/gmail-fetch-message-content-from-cache.module';
-import { GmailFullSyncV2Job } from 'src/modules/messaging/jobs/gmail-full-sync-v2.job';
-import { GmailPartialSyncV2Job } from 'src/modules/messaging/jobs/gmail-partial-sync-v2.job';
+import { GmailFullSynV2Module } from 'src/modules/messaging/services/gmail-full-sync-v2/gmail-full-sync.v2.module';
import { GmailPartialSyncV2Module } from 'src/modules/messaging/services/gmail-partial-sync-v2/gmail-partial-sync-v2.module';
-import { GoogleCalendarSyncCronJob } from 'src/modules/calendar/jobs/crons/google-calendar-sync.cron.job';
-import { CalendarEventParticipantModule } from 'src/modules/calendar/services/calendar-event-participant/calendar-event-participant.module';
-import { UnmatchParticipantJob } from 'src/modules/connected-account/jobs/unmatch-participant.job';
-import { CalendarCreateCompanyAndContactAfterSyncJob } from 'src/modules/calendar/jobs/calendar-create-company-and-contact-after-sync.job';
-import { DeleteConnectedAccountAssociatedCalendarDataJob } from 'src/modules/calendar/jobs/delete-connected-account-associated-calendar-data.job';
-import { FetchAllMessagesFromCacheCronJob } from 'src/modules/messaging/jobs/crons/fetch-all-messages-from-cache.cron.job';
+import { MessageParticipantModule } from 'src/modules/messaging/services/message-participant/message-participant.module';
+import { ThreadCleanerModule } from 'src/modules/messaging/services/thread-cleaner/thread-cleaner.module';
+import { MessageChannelObjectMetadata } from 'src/modules/messaging/standard-objects/message-channel.object-metadata';
@Module({
imports: [
@@ -155,16 +155,16 @@ import { FetchAllMessagesFromCacheCronJob } from 'src/modules/messaging/jobs/cro
useClass: SaveEventToDbJob,
},
{
- provide: FetchAllMessagesFromCacheCronJob.name,
- useClass: FetchAllMessagesFromCacheCronJob,
+ provide: GmailFetchMessagesFromCacheCronJob.name,
+ useClass: GmailFetchMessagesFromCacheCronJob,
},
{
- provide: GmailFullSyncV2Job.name,
- useClass: GmailFullSyncV2Job,
+ provide: GmailFullSyncJob.name,
+ useClass: GmailFullSyncJob,
},
{
- provide: GmailPartialSyncV2Job.name,
- useClass: GmailPartialSyncV2Job,
+ provide: GmailPartialSyncJob.name,
+ useClass: GmailPartialSyncJob,
},
{
provide: GoogleCalendarSyncCronJob.name,
diff --git a/packages/twenty-server/src/modules/calendar/commands/workspace-calendar-sync-commands.module.ts b/packages/twenty-server/src/modules/calendar/commands/calendar-commands.module.ts
similarity index 55%
rename from packages/twenty-server/src/modules/calendar/commands/workspace-calendar-sync-commands.module.ts
rename to packages/twenty-server/src/modules/calendar/commands/calendar-commands.module.ts
index c3fa4544f04..d35fb03d31a 100644
--- a/packages/twenty-server/src/modules/calendar/commands/workspace-calendar-sync-commands.module.ts
+++ b/packages/twenty-server/src/modules/calendar/commands/calendar-commands.module.ts
@@ -1,14 +1,17 @@
import { Module } from '@nestjs/common';
-import { GoogleCalendarSyncCommand } from 'src/modules/calendar/commands/google-calendar-sync.command';
import { ObjectMetadataRepositoryModule } from 'src/engine/object-metadata-repository/object-metadata-repository.module';
+import { GoogleCalendarSyncCommand } from 'src/modules/calendar/commands/google-calendar-sync.command';
+import { CalendarChannelObjectMetadata } from 'src/modules/calendar/standard-objects/calendar-channel.object-metadata';
import { ConnectedAccountObjectMetadata } from 'src/modules/connected-account/standard-objects/connected-account.object-metadata';
-import { StartGoogleCalendarSyncCronJobCommand } from 'src/modules/calendar/commands/start-google-calendar-sync.cron.command';
@Module({
imports: [
- ObjectMetadataRepositoryModule.forFeature([ConnectedAccountObjectMetadata]),
+ ObjectMetadataRepositoryModule.forFeature([
+ ConnectedAccountObjectMetadata,
+ CalendarChannelObjectMetadata,
+ ]),
],
- providers: [GoogleCalendarSyncCommand, StartGoogleCalendarSyncCronJobCommand],
+ providers: [GoogleCalendarSyncCommand],
})
-export class WorkspaceCalendarSyncCommandsModule {}
+export class CalendarCommandsModule {}
diff --git a/packages/twenty-server/src/modules/calendar/crons/commands/calendar-cron-commands.module.ts b/packages/twenty-server/src/modules/calendar/crons/commands/calendar-cron-commands.module.ts
new file mode 100644
index 00000000000..2151e8f13a3
--- /dev/null
+++ b/packages/twenty-server/src/modules/calendar/crons/commands/calendar-cron-commands.module.ts
@@ -0,0 +1,11 @@
+import { Module } from '@nestjs/common';
+
+import { GoogleCalendarSyncCommand } from 'src/modules/calendar/commands/google-calendar-sync.command';
+import { ObjectMetadataRepositoryModule } from 'src/engine/object-metadata-repository/object-metadata-repository.module';
+import { ConnectedAccountObjectMetadata } from 'src/modules/connected-account/standard-objects/connected-account.object-metadata';
+import { GoogleCalendarSyncCronCommand } from 'src/modules/calendar/crons/commands/google-calendar-sync.cron.command';
+
+@Module({
+ providers: [GoogleCalendarSyncCronCommand],
+})
+export class CalendarCronCommandsModule {}
diff --git a/packages/twenty-server/src/modules/calendar/commands/start-google-calendar-sync.cron.command.ts b/packages/twenty-server/src/modules/calendar/crons/commands/google-calendar-sync.cron.command.ts
similarity index 73%
rename from packages/twenty-server/src/modules/calendar/commands/start-google-calendar-sync.cron.command.ts
rename to packages/twenty-server/src/modules/calendar/crons/commands/google-calendar-sync.cron.command.ts
index a0f867659a0..90eeed4a059 100644
--- a/packages/twenty-server/src/modules/calendar/commands/start-google-calendar-sync.cron.command.ts
+++ b/packages/twenty-server/src/modules/calendar/crons/commands/google-calendar-sync.cron.command.ts
@@ -4,14 +4,15 @@ import { Command, CommandRunner } from 'nest-commander';
import { MessageQueue } from 'src/engine/integrations/message-queue/message-queue.constants';
import { MessageQueueService } from 'src/engine/integrations/message-queue/services/message-queue.service';
-import { GoogleCalendarSyncCronJob } from 'src/modules/calendar/jobs/crons/google-calendar-sync.cron.job';
-import { googleCalendarSyncCronPattern } from 'src/modules/calendar/jobs/crons/pattern/google-calendar-sync.cron.pattern';
+import { GoogleCalendarSyncCronJob } from 'src/modules/calendar/crons/jobs/google-calendar-sync.cron.job';
+
+const GOOGLE_CALENDAR_SYNC_CRON_PATTERN = '*/5 * * * *';
@Command({
name: 'cron:calendar:google-calendar-sync',
description: 'Starts a cron job to sync google calendar for all workspaces.',
})
-export class StartGoogleCalendarSyncCronJobCommand extends CommandRunner {
+export class GoogleCalendarSyncCronCommand extends CommandRunner {
constructor(
@Inject(MessageQueue.cronQueue)
private readonly messageQueueService: MessageQueueService,
@@ -24,7 +25,7 @@ export class StartGoogleCalendarSyncCronJobCommand extends CommandRunner {
GoogleCalendarSyncCronJob.name,
undefined,
{
- repeat: { pattern: googleCalendarSyncCronPattern },
+ repeat: { pattern: GOOGLE_CALENDAR_SYNC_CRON_PATTERN },
},
);
}
diff --git a/packages/twenty-server/src/modules/calendar/jobs/crons/google-calendar-sync.cron.job.ts b/packages/twenty-server/src/modules/calendar/crons/jobs/google-calendar-sync.cron.job.ts
similarity index 100%
rename from packages/twenty-server/src/modules/calendar/jobs/crons/google-calendar-sync.cron.job.ts
rename to packages/twenty-server/src/modules/calendar/crons/jobs/google-calendar-sync.cron.job.ts
diff --git a/packages/twenty-server/src/modules/calendar/jobs/crons/pattern/google-calendar-sync.cron.pattern.ts b/packages/twenty-server/src/modules/calendar/jobs/crons/pattern/google-calendar-sync.cron.pattern.ts
deleted file mode 100644
index 2a0d3f7449d..00000000000
--- a/packages/twenty-server/src/modules/calendar/jobs/crons/pattern/google-calendar-sync.cron.pattern.ts
+++ /dev/null
@@ -1 +0,0 @@
-export const googleCalendarSyncCronPattern = '*/5 * * * *';
diff --git a/packages/twenty-server/src/modules/messaging/jobs/crons/gmail-fetch-messages-from-cache.cron.command.ts b/packages/twenty-server/src/modules/messaging/crons/commands/gmail-fetch-messages-from-cache.cron.command.ts
similarity index 82%
rename from packages/twenty-server/src/modules/messaging/jobs/crons/gmail-fetch-messages-from-cache.cron.command.ts
rename to packages/twenty-server/src/modules/messaging/crons/commands/gmail-fetch-messages-from-cache.cron.command.ts
index 9f0013f9cbb..d08eee18cee 100644
--- a/packages/twenty-server/src/modules/messaging/jobs/crons/gmail-fetch-messages-from-cache.cron.command.ts
+++ b/packages/twenty-server/src/modules/messaging/crons/commands/gmail-fetch-messages-from-cache.cron.command.ts
@@ -4,7 +4,7 @@ import { Command, CommandRunner } from 'nest-commander';
import { MessageQueue } from 'src/engine/integrations/message-queue/message-queue.constants';
import { MessageQueueService } from 'src/engine/integrations/message-queue/services/message-queue.service';
-import { FetchAllMessagesFromCacheCronJob } from 'src/modules/messaging/jobs/crons/fetch-all-messages-from-cache.cron.job';
+import { GmailFetchMessagesFromCacheCronJob } from 'src/modules/messaging/crons/jobs/gmail-fetch-messages-from-cache.cron.job';
@Command({
name: 'cron:messaging:gmail-fetch-messages-from-cache',
@@ -20,7 +20,7 @@ export class GmailFetchMessagesFromCacheCronCommand extends CommandRunner {
async run(): Promise<void> {
await this.messageQueueService.addCron<undefined>(
- FetchAllMessagesFromCacheCronJob.name,
+ GmailFetchMessagesFromCacheCronJob.name,
undefined,
{
repeat: {
diff --git a/packages/twenty-server/src/modules/messaging/jobs/crons/gmail-partial-sync.cron.command.ts b/packages/twenty-server/src/modules/messaging/crons/commands/gmail-partial-sync.cron.command.ts
similarity index 72%
rename from packages/twenty-server/src/modules/messaging/jobs/crons/gmail-partial-sync.cron.command.ts
rename to packages/twenty-server/src/modules/messaging/crons/commands/gmail-partial-sync.cron.command.ts
index 2cfe7be3077..3b122ef6de1 100644
--- a/packages/twenty-server/src/modules/messaging/jobs/crons/gmail-partial-sync.cron.command.ts
+++ b/packages/twenty-server/src/modules/messaging/crons/commands/gmail-partial-sync.cron.command.ts
@@ -4,8 +4,9 @@ import { Command, CommandRunner } from 'nest-commander';
import { MessageQueue } from 'src/engine/integrations/message-queue/message-queue.constants';
import { MessageQueueService } from 'src/engine/integrations/message-queue/services/message-queue.service';
-import { GmailPartialSyncCronJob } from 'src/modules/messaging/jobs/crons/gmail-partial-sync.cron.job';
-import { fetchAllWorkspacesMessagesCronPattern } from 'src/modules/messaging/jobs/crons/patterns/fetch-all-workspaces-messages.cron.pattern';
+import { GmailPartialSyncCronJob } from 'src/modules/messaging/crons/jobs/gmail-partial-sync.cron.job';
+
+const GMAIL_PARTIAL_SYNC_CRON_PATTERN = '*/5 * * * *';
@Command({
name: 'cron:messaging:gmail-partial-sync',
@@ -25,7 +26,7 @@ export class GmailPartialSyncCronCommand extends CommandRunner {
GmailPartialSyncCronJob.name,
undefined,
{
- repeat: { pattern: fetchAllWorkspacesMessagesCronPattern },
+ repeat: { pattern: GMAIL_PARTIAL_SYNC_CRON_PATTERN },
},
);
}
diff --git a/packages/twenty-server/src/modules/messaging/commands/messaging-command.module.ts b/packages/twenty-server/src/modules/messaging/crons/commands/messaging-cron-commands.module.ts
similarity index 78%
rename from packages/twenty-server/src/modules/messaging/commands/messaging-command.module.ts
rename to packages/twenty-server/src/modules/messaging/crons/commands/messaging-cron-commands.module.ts
index 48e3c663640..70a16bc9bad 100644
--- a/packages/twenty-server/src/modules/messaging/commands/messaging-command.module.ts
+++ b/packages/twenty-server/src/modules/messaging/crons/commands/messaging-cron-commands.module.ts
@@ -2,8 +2,8 @@ import { Module } from '@nestjs/common';
import { ObjectMetadataRepositoryModule } from 'src/engine/object-metadata-repository/object-metadata-repository.module';
import { ConnectedAccountObjectMetadata } from 'src/modules/connected-account/standard-objects/connected-account.object-metadata';
-import { GmailFetchMessagesFromCacheCronCommand } from 'src/modules/messaging/jobs/crons/gmail-fetch-messages-from-cache.cron.command';
-import { GmailPartialSyncCronCommand } from 'src/modules/messaging/jobs/crons/gmail-partial-sync.cron.command';
+import { GmailFetchMessagesFromCacheCronCommand } from 'src/modules/messaging/crons/commands/gmail-fetch-messages-from-cache.cron.command';
+import { GmailPartialSyncCronCommand } from 'src/modules/messaging/crons/commands/gmail-partial-sync.cron.command';
@Module({
imports: [
ObjectMetadataRepositoryModule.forFeature([ConnectedAccountObjectMetadata]),
@@ -13,4 +13,4 @@ import { GmailPartialSyncCronCommand } from 'src/modules/messaging/jobs/crons/gm
GmailFetchMessagesFromCacheCronCommand,
],
})
-export class MessagingCommandModule {}
+export class MessagingCronCommandsModule {}
diff --git a/packages/twenty-server/src/modules/messaging/jobs/crons/fetch-all-messages-from-cache.cron.job.ts b/packages/twenty-server/src/modules/messaging/crons/jobs/gmail-fetch-messages-from-cache.cron.job.ts
similarity index 98%
rename from packages/twenty-server/src/modules/messaging/jobs/crons/fetch-all-messages-from-cache.cron.job.ts
rename to packages/twenty-server/src/modules/messaging/crons/jobs/gmail-fetch-messages-from-cache.cron.job.ts
index 8ed5ea6107e..a9c75fc5e2d 100644
--- a/packages/twenty-server/src/modules/messaging/jobs/crons/fetch-all-messages-from-cache.cron.job.ts
+++ b/packages/twenty-server/src/modules/messaging/crons/jobs/gmail-fetch-messages-from-cache.cron.job.ts
@@ -13,7 +13,7 @@ import { MessageChannelObjectMetadata } from 'src/modules/messaging/standard-obj
import { GmailFetchMessageContentFromCacheService } from 'src/modules/messaging/services/gmail-fetch-message-content-from-cache/gmail-fetch-message-content-from-cache.service';
@Injectable()
-export class FetchAllMessagesFromCacheCronJob
+export class GmailFetchMessagesFromCacheCronJob
implements MessageQueueJob<undefined>
{
constructor(
diff --git a/packages/twenty-server/src/modules/messaging/jobs/crons/gmail-partial-sync.cron.job.ts b/packages/twenty-server/src/modules/messaging/crons/jobs/gmail-partial-sync.cron.job.ts
similarity index 91%
rename from packages/twenty-server/src/modules/messaging/jobs/crons/gmail-partial-sync.cron.job.ts
rename to packages/twenty-server/src/modules/messaging/crons/jobs/gmail-partial-sync.cron.job.ts
index 905a84d2290..03b09c3ecab 100644
--- a/packages/twenty-server/src/modules/messaging/jobs/crons/gmail-partial-sync.cron.job.ts
+++ b/packages/twenty-server/src/modules/messaging/crons/jobs/gmail-partial-sync.cron.job.ts
@@ -13,9 +13,9 @@ import { DataSourceEntity } from 'src/engine/metadata-modules/data-source/data-s
import { InjectObjectMetadataRepository } from 'src/engine/object-metadata-repository/object-metadata-repository.decorator';
import { ConnectedAccountObjectMetadata } from 'src/modules/connected-account/standard-objects/connected-account.object-metadata';
import {
- GmailPartialSyncV2Job as GmailPartialSyncV2Job,
- GmailPartialSyncV2JobData as GmailPartialSyncV2JobData,
-} from 'src/modules/messaging/jobs/gmail-partial-sync-v2.job';
+ GmailPartialSyncJob as GmailPartialSyncJob,
+ GmailPartialSyncJobData as GmailPartialSyncJobData,
+} from 'src/modules/messaging/jobs/gmail-partial-sync.job';
@Injectable()
export class GmailPartialSyncCronJob implements MessageQueueJob<undefined> {
@@ -63,8 +63,8 @@ export class GmailPartialSyncCronJob implements MessageQueueJob<undefined> {
await this.connectedAccountRepository.getAll(workspaceId);
for (const connectedAccount of connectedAccounts) {
- await this.messageQueueService.add<GmailPartialSyncV2JobData>(
- GmailPartialSyncV2Job.name,
+ await this.messageQueueService.add<GmailPartialSyncJobData>(
+ GmailPartialSyncJob.name,
{
workspaceId,
connectedAccountId: connectedAccount.id,
diff --git a/packages/twenty-server/src/modules/messaging/jobs/crons/patterns/fetch-all-workspaces-messages.cron.pattern.ts b/packages/twenty-server/src/modules/messaging/jobs/crons/patterns/fetch-all-workspaces-messages.cron.pattern.ts
deleted file mode 100644
index 83d6b6db044..00000000000
--- a/packages/twenty-server/src/modules/messaging/jobs/crons/patterns/fetch-all-workspaces-messages.cron.pattern.ts
+++ /dev/null
@@ -1 +0,0 @@
-export const fetchAllWorkspacesMessagesCronPattern = '*/5 * * * *';
diff --git a/packages/twenty-server/src/modules/messaging/jobs/gmail-full-sync-v2.job.ts b/packages/twenty-server/src/modules/messaging/jobs/gmail-full-sync.job.ts
similarity index 84%
rename from packages/twenty-server/src/modules/messaging/jobs/gmail-full-sync-v2.job.ts
rename to packages/twenty-server/src/modules/messaging/jobs/gmail-full-sync.job.ts
index ac90589f5a8..427c6e141ff 100644
--- a/packages/twenty-server/src/modules/messaging/jobs/gmail-full-sync-v2.job.ts
+++ b/packages/twenty-server/src/modules/messaging/jobs/gmail-full-sync.job.ts
@@ -5,23 +5,21 @@ import { MessageQueueJob } from 'src/engine/integrations/message-queue/interface
import { GoogleAPIRefreshAccessTokenService } from 'src/modules/connected-account/services/google-api-refresh-access-token/google-api-refresh-access-token.service';
import { GmailFullSyncV2Service } from 'src/modules/messaging/services/gmail-full-sync-v2/gmail-full-sync.v2.service';
-export type GmailFullSyncV2JobData = {
+export type GmailFullSyncJobData = {
workspaceId: string;
connectedAccountId: string;
};
@Injectable()
-export class GmailFullSyncV2Job
- implements MessageQueueJob<GmailFullSyncV2JobData>
-{
- private readonly logger = new Logger(GmailFullSyncV2Job.name);
+export class GmailFullSyncJob implements MessageQueueJob<GmailFullSyncJobData> {
+ private readonly logger = new Logger(GmailFullSyncJob.name);
constructor(
private readonly googleAPIsRefreshAccessTokenService: GoogleAPIRefreshAccessTokenService,
private readonly gmailFullSyncV2Service: GmailFullSyncV2Service,
) {}
- async handle(data: GmailFullSyncV2JobData): Promise<void> {
+ async handle(data: GmailFullSyncJobData): Promise<void> {
this.logger.log(
`gmail full-sync for workspace ${data.workspaceId} and account ${data.connectedAccountId}`,
);
diff --git a/packages/twenty-server/src/modules/messaging/jobs/gmail-partial-sync-v2.job.ts b/packages/twenty-server/src/modules/messaging/jobs/gmail-partial-sync.job.ts
similarity index 83%
rename from packages/twenty-server/src/modules/messaging/jobs/gmail-partial-sync-v2.job.ts
rename to packages/twenty-server/src/modules/messaging/jobs/gmail-partial-sync.job.ts
index d327e0ebc3a..bc1e6c28342 100644
--- a/packages/twenty-server/src/modules/messaging/jobs/gmail-partial-sync-v2.job.ts
+++ b/packages/twenty-server/src/modules/messaging/jobs/gmail-partial-sync.job.ts
@@ -5,23 +5,23 @@ import { MessageQueueJob } from 'src/engine/integrations/message-queue/interface
import { GoogleAPIRefreshAccessTokenService } from 'src/modules/connected-account/services/google-api-refresh-access-token/google-api-refresh-access-token.service';
import { GmailPartialSyncV2Service } from 'src/modules/messaging/services/gmail-partial-sync-v2/gmail-partial-sync-v2.service';
-export type GmailPartialSyncV2JobData = {
+export type GmailPartialSyncJobData = {
workspaceId: string;
connectedAccountId: string;
};
@Injectable()
-export class GmailPartialSyncV2Job
- implements MessageQueueJob<GmailPartialSyncV2JobData>
+export class GmailPartialSyncJob
+ implements MessageQueueJob<GmailPartialSyncJobData>
{
- private readonly logger = new Logger(GmailPartialSyncV2Job.name);
+ private readonly logger = new Logger(GmailPartialSyncJob.name);
constructor(
private readonly googleAPIsRefreshAccessTokenService: GoogleAPIRefreshAccessTokenService,
private readonly gmailPartialSyncV2Service: GmailPartialSyncV2Service,
) {}
- async handle(data: GmailPartialSyncV2JobData): Promise<void> {
+ async handle(data: GmailPartialSyncJobData): Promise<void> {
this.logger.log(
`gmail partial-sync for workspace ${data.workspaceId} and account ${data.connectedAccountId}`,
);
diff --git a/packages/twenty-server/src/modules/messaging/services/gmail-fetch-message-content-from-cache/gmail-fetch-message-content-from-cache.service.ts b/packages/twenty-server/src/modules/messaging/services/gmail-fetch-message-content-from-cache/gmail-fetch-message-content-from-cache.service.ts
index e4e6d4cd117..21614a8a9b0 100644
--- a/packages/twenty-server/src/modules/messaging/services/gmail-fetch-message-content-from-cache/gmail-fetch-message-content-from-cache.service.ts
+++ b/packages/twenty-server/src/modules/messaging/services/gmail-fetch-message-content-from-cache/gmail-fetch-message-content-from-cache.service.ts
@@ -19,9 +19,9 @@ import { GMAIL_USERS_MESSAGES_GET_BATCH_SIZE } from 'src/modules/messaging/const
import { WorkspaceDataSourceService } from 'src/engine/workspace-datasource/workspace-datasource.service';
import { SaveMessageAndEmitContactCreationEventService } from 'src/modules/messaging/services/save-message-and-emit-contact-creation-event/save-message-and-emit-contact-creation-event.service';
import {
- GmailFullSyncV2JobData,
- GmailFullSyncV2Job,
-} from 'src/modules/messaging/jobs/gmail-full-sync-v2.job';
+ GmailFullSyncJobData,
+ GmailFullSyncJob,
+} from 'src/modules/messaging/jobs/gmail-full-sync.job';
import { MessageQueue } from 'src/engine/integrations/message-queue/message-queue.constants';
import { MessageQueueService } from 'src/engine/integrations/message-queue/services/message-queue.service';
import { GMAIL_ONGOING_SYNC_TIMEOUT } from 'src/modules/messaging/constants/gmail-ongoing-sync-timeout.constant';
@@ -265,8 +265,8 @@ export class GmailFetchMessageContentFromCacheService {
workspaceId: string,
connectedAccountId: string,
) {
- await this.messageQueueService.add<GmailFullSyncV2JobData>(
- GmailFullSyncV2Job.name,
+ await this.messageQueueService.add<GmailFullSyncJobData>(
+ GmailFullSyncJob.name,
{ workspaceId, connectedAccountId },
);
}
diff --git a/packages/twenty-server/src/modules/messaging/services/gmail-partial-sync-v2/gmail-partial-sync-v2.service.ts b/packages/twenty-server/src/modules/messaging/services/gmail-partial-sync-v2/gmail-partial-sync-v2.service.ts
index 3bba4c43c4a..cb64d92475b 100644
--- a/packages/twenty-server/src/modules/messaging/services/gmail-partial-sync-v2/gmail-partial-sync-v2.service.ts
+++ b/packages/twenty-server/src/modules/messaging/services/gmail-partial-sync-v2/gmail-partial-sync-v2.service.ts
@@ -21,9 +21,9 @@ import { InjectCacheStorage } from 'src/engine/integrations/cache-storage/decora
import { CacheStorageNamespace } from 'src/engine/integrations/cache-storage/types/cache-storage-namespace.enum';
import { WorkspaceDataSourceService } from 'src/engine/workspace-datasource/workspace-datasource.service';
import {
- GmailFullSyncV2Job,
- GmailFullSyncV2JobData,
-} from 'src/modules/messaging/jobs/gmail-full-sync-v2.job';
+ GmailFullSyncJob,
+ GmailFullSyncJobData,
+} from 'src/modules/messaging/jobs/gmail-full-sync.job';
@Injectable()
export class GmailPartialSyncV2Service {
@@ -330,8 +330,8 @@ export class GmailPartialSyncV2Service {
workspaceId: string,
connectedAccountId: string,
) {
- await this.messageQueueService.add<GmailFullSyncV2JobData>(
- GmailFullSyncV2Job.name,
+ await this.messageQueueService.add<GmailFullSyncJobData>(
+ GmailFullSyncJob.name,
{ workspaceId, connectedAccountId },
);
}