3239 create a command to do a partial sync with the gmail api using the historyid (#3405)

* create utils service

* getLastSyncHistoryId

* getHistory

* add historyTypes messageAdded and messageDeleted

* getMessageIdsAndThreadIdsNotInDatabase

* wip

* fix messageThreadId null

* no need to fetch threads anymore

* get messagesAdded in partial sync

* adding errors

* save lastSyncHistoryId

* improve

* renaming

* create partial sync job

* improve partial sync

* adding messages with partial sync is working

* now adding messages with partial sync is working

* deleting messages and empty threads is working

* wip

* wip

* fix bug to delete threads

* update partial sync to cover edge cases

* renaming

* modify ambiguous naming

* renaming
This commit is contained in:
bosiraphael
2024-01-12 17:46:55 +01:00
committed by GitHub
parent 4f306f8955
commit 5a61e34f4c
18 changed files with 705 additions and 296 deletions

View File

@ -5,12 +5,12 @@ import { v4 } from 'uuid';
import { DataSourceService } from 'src/metadata/data-source/data-source.service';
import { TypeORMService } from 'src/database/typeorm/typeorm.service';
import { SaveConnectedAccountInput } from 'src/core/auth/dto/save-connected-account';
import {
FetchAllMessagesFromConnectedAccountJobData,
FetchAllMessagesFromConnectedAccountJob,
} from 'src/workspace/messaging/jobs/fetch-all-messages-from-connected-account.job';
import { MessageQueue } from 'src/integrations/message-queue/message-queue.constants';
import { MessageQueueService } from 'src/integrations/message-queue/services/message-queue.service';
import {
GmailFullSyncJob,
GmailFullSyncJobData,
} from 'src/workspace/messaging/jobs/gmail-full-sync.job';
@Injectable()
export class GoogleGmailService {
@ -73,8 +73,8 @@ export class GoogleGmailService {
);
});
await this.messageQueueService.add<FetchAllMessagesFromConnectedAccountJobData>(
FetchAllMessagesFromConnectedAccountJob.name,
await this.messageQueueService.add<GmailFullSyncJobData>(
GmailFullSyncJob.name,
{
workspaceId,
connectedAccountId,