Fix fetchAllMessages cronJob when deleted datasource (#4355)

This commit is contained in:
Weiko 2024-03-07 12:31:57 +01:00 committed by GitHub
parent e8252eca86
commit e7733a1b7a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,4 +1,4 @@
import { Inject, Injectable } from '@nestjs/common';
import { Inject, Injectable, Logger } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Repository } from 'typeorm';
@ -8,16 +8,18 @@ import { MessageQueueJob } from 'src/integrations/message-queue/interfaces/messa
import { MessageQueue } from 'src/integrations/message-queue/message-queue.constants';
import { MessageQueueService } from 'src/integrations/message-queue/services/message-queue.service';
import { ConnectedAccountService } from 'src/workspace/messaging/repositories/connected-account/connected-account.service';
import { Workspace } from 'src/core/workspace/workspace.entity';
import {
GmailPartialSyncJobData,
GmailPartialSyncJob,
} from 'src/workspace/messaging/jobs/gmail-partial-sync.job';
import { Workspace } from 'src/core/workspace/workspace.entity';
@Injectable()
export class FetchAllWorkspacesMessagesJob
implements MessageQueueJob<undefined>
{
private readonly logger = new Logger(FetchAllWorkspacesMessagesJob.name);
constructor(
@InjectRepository(Workspace, 'core')
private readonly workspaceRepository: Repository<Workspace>,
@ -42,6 +44,7 @@ export class FetchAllWorkspacesMessagesJob
}
private async fetchWorkspaceMessages(workspaceId: string): Promise<void> {
try {
const connectedAccounts =
await this.connectedAccountService.getAll(workspaceId);
@ -57,5 +60,13 @@ export class FetchAllWorkspacesMessagesJob
},
);
}
} catch (error) {
this.logger.error(
`Error while fetching workspace messages for workspace ${workspaceId}`,
);
this.logger.error(error);
return;
}
}
}