2880 timebox create a poc to fetch emails from the gmail api (#2993)
* create empty service * getting threads is working * insert message channel * save threads in the db * clean * fetch messages * create a service to fetch a batch of messages * batch messages * use httpService instead * parse batch * base 64 decoding working * solve parsing bug * saving messages is working * bug to fix in fetchAllByBatches * fetching all messages is working but not saving yet * fecth 500 messages and threads is working * remove unused package and console log * set direction to incoming * fix bug after merging main
This commit is contained in:
@ -2,9 +2,10 @@ import { Module } from '@nestjs/common';
|
||||
|
||||
import { FetchWorkspaceMessagesCommand } from 'src/workspace/messaging/commands/fetch-workspace-messages.command';
|
||||
import { MessagingModule } from 'src/workspace/messaging/messaging.module';
|
||||
import { FetchWorkspaceMessagesModule } from 'src/workspace/messaging/services/fetch-workspace-messages.module';
|
||||
|
||||
@Module({
|
||||
imports: [MessagingModule],
|
||||
imports: [MessagingModule, FetchWorkspaceMessagesModule],
|
||||
providers: [FetchWorkspaceMessagesCommand],
|
||||
})
|
||||
export class FetchWorkspaceMessagesCommandsModule {}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
import { Command, CommandRunner, Option } from 'nest-commander';
|
||||
|
||||
import { FetchWorkspaceMessagesService } from 'src/workspace/messaging/services/fetch-workspace-messages.service';
|
||||
import { MessagingProducer } from 'src/workspace/messaging/producers/messaging-producer';
|
||||
|
||||
interface FetchWorkspaceMessagesOptions {
|
||||
@ -11,7 +12,10 @@ interface FetchWorkspaceMessagesOptions {
|
||||
description: 'Fetch messages of all workspaceMembers in a workspace.',
|
||||
})
|
||||
export class FetchWorkspaceMessagesCommand extends CommandRunner {
|
||||
constructor(private readonly messagingProducer: MessagingProducer) {
|
||||
constructor(
|
||||
private readonly fetchWorkspaceMessagesService: FetchWorkspaceMessagesService,
|
||||
private readonly messagingProducer: MessagingProducer,
|
||||
) {
|
||||
super();
|
||||
}
|
||||
|
||||
@ -24,6 +28,14 @@ export class FetchWorkspaceMessagesCommand extends CommandRunner {
|
||||
options.workspaceId,
|
||||
);
|
||||
|
||||
await this.fetchWorkspaceMessagesService.fetchWorkspaceThreads(
|
||||
options.workspaceId,
|
||||
);
|
||||
|
||||
await this.fetchWorkspaceMessagesService.fetchWorkspaceMessages(
|
||||
options.workspaceId,
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user