Simplify events structure and fix minor issues

This commit is contained in:
Stênio Aníbal
2024-08-23 10:53:31 -03:00
parent beb7942d7c
commit 05ee65f422
28 changed files with 475 additions and 698 deletions

View File

@@ -2,10 +2,10 @@ import { InstanceDto } from '@api/dto/instance.dto';
import { PrismaRepository } from '@api/repository/repository.service';
import {
difyController,
eventManager,
genericController,
openaiController,
typebotController,
websocketController,
} from '@api/server.module';
import { WAMonitoringService } from '@api/services/monitor.service';
import { Logger } from '@config/logger.config';
@@ -102,12 +102,13 @@ export class ChatbotController {
await genericController.emit(emitData);
}
public async setInstance(instanceName: string, data: any): Promise<any> {
// chatwoot
if (data.websocketEnabled)
await websocketController.set(instanceName, {
enabled: true,
events: data.websocketEvents,
public async setInstance(instanceName: string, data: InstanceDto): Promise<any> {
if (data.websocket.enabled)
await eventManager.websocket.set(instanceName, {
websocket: {
enabled: true,
events: data.websocket.events,
},
});
}
@@ -200,7 +201,7 @@ export class ChatbotController {
instance: InstanceDto,
session?: IntegrationSession,
) {
let findBot = null;
let findBot: null;
if (!session) {
findBot = await findBotByTrigger(botRepository, settingsRepository, content, instance.instanceId);