fix: get integrations sessions by type

This commit is contained in:
Davidson Gomes
2024-08-24 13:18:58 -03:00
parent a90617fa0c
commit aeea61ef4b
18 changed files with 403 additions and 398 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+2 -2
View File
@@ -5,8 +5,8 @@
<link rel="icon" type="image/png" href="/assets/images/evolution-logo.png" /> <link rel="icon" type="image/png" href="/assets/images/evolution-logo.png" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Evolution Manager</title> <title>Evolution Manager</title>
<script type="module" crossorigin src="/assets/index-BpEDJ12n.js"></script> <script type="module" crossorigin src="/assets/index-PmD1d8Kz.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-BJ9JMAl_.css"> <link rel="stylesheet" crossorigin href="/assets/index-DvXIV-Pi.css">
</head> </head>
<body> <body>
<div id="root"></div> <div id="root"></div>
@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "IntegrationSession" ADD COLUMN "type" VARCHAR(100);
+1
View File
@@ -397,6 +397,7 @@ model IntegrationSession {
status SessionStatus status SessionStatus
awaitUser Boolean @default(false) @db.Boolean awaitUser Boolean @default(false) @db.Boolean
context Json? context Json?
type String? @db.VarChar(100)
createdAt DateTime? @default(now()) @db.Timestamp createdAt DateTime? @default(now()) @db.Timestamp
updatedAt DateTime @updatedAt @db.Timestamp updatedAt DateTime @updatedAt @db.Timestamp
Message Message[] Message Message[]
@@ -649,6 +649,7 @@ export class DifyController extends ChatbotController implements ChatbotControll
instanceId: instanceId, instanceId: instanceId,
remoteJid, remoteJid,
botId: bot ? botId : { not: null }, botId: bot ? botId : { not: null },
type: 'dify',
}, },
}); });
} catch (error) { } catch (error) {
@@ -29,6 +29,7 @@ export class DifyService {
awaitUser: false, awaitUser: false,
botId: data.botId, botId: data.botId,
instanceId: instance.instanceId, instanceId: instance.instanceId,
type: 'dify',
}, },
}); });
@@ -3,12 +3,12 @@ import { InstanceDto } from '@api/dto/instance.dto';
import { PrismaRepository } from '@api/repository/repository.service'; import { PrismaRepository } from '@api/repository/repository.service';
import { WAMonitoringService } from '@api/services/monitor.service'; import { WAMonitoringService } from '@api/services/monitor.service';
import { Logger } from '@config/logger.config'; import { Logger } from '@config/logger.config';
import { Flowise } from '@prisma/client';
import { getConversationMessage } from '@utils/getConversationMessage'; import { getConversationMessage } from '@utils/getConversationMessage';
import { ChatbotController, ChatbotControllerInterface, EmitData } from '../../chatbot.controller'; import { ChatbotController, ChatbotControllerInterface, EmitData } from '../../chatbot.controller';
import { FlowiseDto } from '../dto/flowise.dto'; import { FlowiseDto } from '../dto/flowise.dto';
import { FlowiseService } from '../services/flowise.service'; import { FlowiseService } from '../services/flowise.service';
import { Flowise } from '@prisma/client';
export class FlowiseController extends ChatbotController implements ChatbotControllerInterface { export class FlowiseController extends ChatbotController implements ChatbotControllerInterface {
constructor( constructor(
@@ -625,6 +625,7 @@ export class FlowiseController extends ChatbotController implements ChatbotContr
instanceId: instanceId, instanceId: instanceId,
remoteJid, remoteJid,
botId: bot ? botId : { not: null }, botId: bot ? botId : { not: null },
type: 'flowise',
}, },
}); });
} catch (error) { } catch (error) {
@@ -28,6 +28,7 @@ export class FlowiseService {
awaitUser: false, awaitUser: false,
botId: data.botId, botId: data.botId,
instanceId: instance.instanceId, instanceId: instance.instanceId,
type: 'flowise',
}, },
}); });
@@ -625,6 +625,7 @@ export class GenericController extends ChatbotController implements ChatbotContr
instanceId: instanceId, instanceId: instanceId,
remoteJid, remoteJid,
botId: bot ? botId : { not: null }, botId: bot ? botId : { not: null },
type: 'generic',
}, },
}); });
} catch (error) { } catch (error) {
@@ -28,6 +28,7 @@ export class GenericService {
awaitUser: false, awaitUser: false,
botId: data.botId, botId: data.botId,
instanceId: instance.instanceId, instanceId: instance.instanceId,
type: 'generic',
}, },
}); });
@@ -363,9 +363,6 @@ export class OpenaiController extends ChatbotController implements ChatbotContro
where: { where: {
instanceId, instanceId,
}, },
include: {
sessions: true,
},
}); });
if (!bots.length) { if (!bots.length) {
@@ -390,9 +387,6 @@ export class OpenaiController extends ChatbotController implements ChatbotContro
where: { where: {
id: botId, id: botId,
}, },
include: {
sessions: true,
},
}); });
if (!bot) { if (!bot) {
@@ -864,9 +858,7 @@ export class OpenaiController extends ChatbotController implements ChatbotContro
instanceId: instanceId, instanceId: instanceId,
remoteJid, remoteJid,
botId: openaiBot ? botId : { not: null }, botId: openaiBot ? botId : { not: null },
}, type: 'openai',
include: {
OpenaiBot: true,
}, },
}); });
} catch (error) { } catch (error) {
@@ -244,6 +244,7 @@ export class OpenaiService {
awaitUser: false, awaitUser: false,
botId: data.botId, botId: data.botId,
instanceId: instance.instanceId, instanceId: instance.instanceId,
type: 'openai',
}, },
}); });
} }
@@ -534,6 +535,7 @@ export class OpenaiService {
awaitUser: false, awaitUser: false,
botId: data.botId, botId: data.botId,
instanceId: instance.instanceId, instanceId: instance.instanceId,
type: 'openai',
}, },
}); });
@@ -911,6 +911,7 @@ export class TypebotController extends ChatbotController implements ChatbotContr
instanceId: instanceId, instanceId: instanceId,
remoteJid, remoteJid,
botId: botId ?? { not: null }, botId: botId ?? { not: null },
type: 'typebot',
}, },
}); });
} catch (error) { } catch (error) {
@@ -78,6 +78,7 @@ export class TypebotService {
awaitUser: false, awaitUser: false,
botId: data.botId, botId: data.botId,
instanceId: instance.id, instanceId: instance.id,
type: 'typebot',
}, },
}); });
} }
+4 -4
View File
@@ -99,7 +99,7 @@ export class EventManager {
if (data.websocket) if (data.websocket)
await this.websocket.set(instanceName, { await this.websocket.set(instanceName, {
websocket: { websocket: {
enabled: data.websocket?.enabled, enabled: true,
events: data.websocket?.events, events: data.websocket?.events,
}, },
}); });
@@ -107,7 +107,7 @@ export class EventManager {
if (data.rabbitmq) if (data.rabbitmq)
await this.rabbitmq.set(instanceName, { await this.rabbitmq.set(instanceName, {
rabbitmq: { rabbitmq: {
enabled: data.rabbitmq?.enabled, enabled: true,
events: data.rabbitmq?.events, events: data.rabbitmq?.events,
}, },
}); });
@@ -115,7 +115,7 @@ export class EventManager {
if (data.sqs) if (data.sqs)
await this.sqs.set(instanceName, { await this.sqs.set(instanceName, {
sqs: { sqs: {
enabled: data.sqs?.enabled, enabled: true,
events: data.sqs?.events, events: data.sqs?.events,
}, },
}); });
@@ -123,7 +123,7 @@ export class EventManager {
if (data.webhook) if (data.webhook)
await this.webhook.set(instanceName, { await this.webhook.set(instanceName, {
webhook: { webhook: {
enabled: data.webhook?.enabled, enabled: true,
events: data.webhook?.events, events: data.webhook?.events,
url: data.webhook?.url, url: data.webhook?.url,
base64: data.webhook?.base64, base64: data.webhook?.base64,