4971 add issyncenabled toggle in messaging settings (#4995)
- Closes #4971 - Fix calendar import to take isSyncEnabled into account
This commit is contained in:
@ -11,10 +11,7 @@ import {
|
||||
} from 'src/engine/core-modules/feature-flag/feature-flag.entity';
|
||||
import { Workspace } from 'src/engine/core-modules/workspace/workspace.entity';
|
||||
import { DataSourceEntity } from 'src/engine/metadata-modules/data-source/data-source.entity';
|
||||
import { InjectObjectMetadataRepository } from 'src/engine/object-metadata-repository/object-metadata-repository.decorator';
|
||||
import { CalendarChannelRepository } from 'src/modules/calendar/repositories/calendar-channel.repository';
|
||||
import { CalendarChannelObjectMetadata } from 'src/modules/calendar/standard-objects/calendar-channel.object-metadata';
|
||||
import { GoogleCalendarSyncService } from 'src/modules/calendar/services/google-calendar-sync.service';
|
||||
import { WorkspaceGoogleCalendarSyncService } from 'src/modules/calendar/services/workspace-google-calendar-sync/workspace-google-calendar-sync.service';
|
||||
|
||||
@Injectable()
|
||||
export class GoogleCalendarSyncCronJob implements MessageQueueJob<undefined> {
|
||||
@ -23,11 +20,9 @@ export class GoogleCalendarSyncCronJob implements MessageQueueJob<undefined> {
|
||||
private readonly workspaceRepository: Repository<Workspace>,
|
||||
@InjectRepository(DataSourceEntity, 'metadata')
|
||||
private readonly dataSourceRepository: Repository<DataSourceEntity>,
|
||||
@InjectObjectMetadataRepository(CalendarChannelObjectMetadata)
|
||||
private readonly calendarChannelRepository: CalendarChannelRepository,
|
||||
@InjectRepository(FeatureFlagEntity, 'core')
|
||||
private readonly featureFlagRepository: Repository<FeatureFlagEntity>,
|
||||
private readonly googleCalendarSyncService: GoogleCalendarSyncService,
|
||||
private readonly workspaceGoogleCalendarSyncService: WorkspaceGoogleCalendarSyncService,
|
||||
) {}
|
||||
|
||||
async handle(): Promise<void> {
|
||||
@ -62,20 +57,8 @@ export class GoogleCalendarSyncCronJob implements MessageQueueJob<undefined> {
|
||||
);
|
||||
|
||||
for (const workspaceId of workspaceIdsWithDataSources) {
|
||||
await this.startWorkspaceGoogleCalendarSync(workspaceId);
|
||||
}
|
||||
}
|
||||
|
||||
private async startWorkspaceGoogleCalendarSync(
|
||||
workspaceId: string,
|
||||
): Promise<void> {
|
||||
const calendarChannels =
|
||||
await this.calendarChannelRepository.getAll(workspaceId);
|
||||
|
||||
for (const calendarChannel of calendarChannels) {
|
||||
await this.googleCalendarSyncService.startGoogleCalendarSync(
|
||||
await this.workspaceGoogleCalendarSyncService.startWorkspaceGoogleCalendarSync(
|
||||
workspaceId,
|
||||
calendarChannel.connectedAccountId,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user