* 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
46 lines
1.2 KiB
TypeScript
46 lines
1.2 KiB
TypeScript
import { Inject, Injectable } from '@nestjs/common';
|
|
|
|
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';
|
|
import {
|
|
GmailPartialSyncJob,
|
|
GmailPartialSyncJobData,
|
|
} from 'src/workspace/messaging/jobs/gmail-partial-sync.job';
|
|
|
|
@Injectable()
|
|
export class MessagingProducer {
|
|
constructor(
|
|
@Inject(MessageQueue.messagingQueue)
|
|
private readonly messageQueueService: MessageQueueService,
|
|
) {}
|
|
|
|
async enqueueGmailFullSync(data: GmailFullSyncJobData, singletonKey: string) {
|
|
await this.messageQueueService.add<GmailFullSyncJobData>(
|
|
GmailFullSyncJob.name,
|
|
data,
|
|
{
|
|
id: singletonKey,
|
|
retryLimit: 2,
|
|
},
|
|
);
|
|
}
|
|
|
|
async enqueueGmailPartialSync(
|
|
data: GmailPartialSyncJobData,
|
|
singletonKey: string,
|
|
) {
|
|
await this.messageQueueService.add<GmailPartialSyncJobData>(
|
|
GmailPartialSyncJob.name,
|
|
data,
|
|
{
|
|
id: singletonKey,
|
|
retryLimit: 2,
|
|
},
|
|
);
|
|
}
|
|
}
|