[Messaging] Gmail Full sync pagination (#3664)

This commit is contained in:
Weiko
2024-01-29 11:57:54 +01:00
committed by GitHub
parent a654205dbc
commit d66d8c9907
11 changed files with 128 additions and 129 deletions

View File

@ -9,6 +9,7 @@ import { GmailFullSyncService } from 'src/workspace/messaging/services/gmail-ful
export type GmailFullSyncJobData = {
workspaceId: string;
connectedAccountId: string;
nextPageToken?: string;
};
@Injectable()
@ -21,8 +22,10 @@ export class GmailFullSyncJob implements MessageQueueJob<GmailFullSyncJobData> {
async handle(data: GmailFullSyncJobData): Promise<void> {
console.log(
`fetching messages for workspace ${data.workspaceId} and account ${
`gmail full-sync for workspace ${data.workspaceId} and account ${
data.connectedAccountId
} ${
data.nextPageToken ? `and ${data.nextPageToken} pageToken` : ''
} with ${this.environmentService.getMessageQueueDriverType()}`,
);
await this.gmailRefreshAccessTokenService.refreshAndSaveAccessToken(
@ -33,6 +36,7 @@ export class GmailFullSyncJob implements MessageQueueJob<GmailFullSyncJobData> {
await this.fetchWorkspaceMessagesService.fetchConnectedAccountThreads(
data.workspaceId,
data.connectedAccountId,
data.nextPageToken,
);
}
}

View File

@ -23,7 +23,7 @@ export class GmailPartialSyncJob
async handle(data: GmailPartialSyncJobData): Promise<void> {
console.log(
`fetching messages for workspace ${data.workspaceId} and account ${
`gmail partial-sync for workspace ${data.workspaceId} and account ${
data.connectedAccountId
} with ${this.environmentService.getMessageQueueDriverType()}`,
);