mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-26 10:28:38 -06:00
Fixes Typebot.start, fetchSessions and adds typebot composite key migration
This commit is contained in:
parent
2784b907b0
commit
a6326861da
@ -0,0 +1,8 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- A unique constraint covering the columns `[url,typebot,instanceId]` on the table `Typebot` will be added. If there are existing duplicate values, this will fail.
|
||||
|
||||
*/
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "Typebot_url_typebot_instanceId_key" ON "Typebot"("url", "typebot", "instanceId");
|
@ -311,6 +311,8 @@ model Typebot {
|
||||
Instance Instance @relation(fields: [instanceId], references: [id], onDelete: Cascade)
|
||||
instanceId String
|
||||
TypebotSetting TypebotSetting[]
|
||||
|
||||
@@unique([url, typebot, instanceId], name: "url_typebot_instanceId")
|
||||
}
|
||||
|
||||
model TypebotSetting {
|
||||
|
@ -682,7 +682,7 @@ export class TypebotController extends ChatbotController implements ChatbotContr
|
||||
stopBotFromMe: stopBotFromMe,
|
||||
keepOpen: keepOpen,
|
||||
prefilledVariables: prefilledVariables,
|
||||
typebotId: findBot.id,
|
||||
botId: findBot.id
|
||||
});
|
||||
|
||||
if (response.sessionId) {
|
||||
@ -889,7 +889,7 @@ export class TypebotController extends ChatbotController implements ChatbotContr
|
||||
throw new Error('Typebot not found');
|
||||
}
|
||||
|
||||
return await this.sessionRepository.findMany({
|
||||
const sessions = await this.sessionRepository.findMany({
|
||||
where: {
|
||||
instanceId: instanceId,
|
||||
remoteJid,
|
||||
@ -897,6 +897,8 @@ export class TypebotController extends ChatbotController implements ChatbotContr
|
||||
type: 'typebot',
|
||||
},
|
||||
});
|
||||
|
||||
return sessions;
|
||||
} catch (error) {
|
||||
this.logger.error(error);
|
||||
throw new Error('Error fetching sessions');
|
||||
|
@ -113,7 +113,7 @@ export class TypebotRouter extends RouterBroker {
|
||||
request: req,
|
||||
schema: instanceSchema,
|
||||
ClassRef: InstanceDto,
|
||||
execute: (instance) => typebotController.fetchSessions(instance, req.params.typebotId),
|
||||
execute: (instance) => typebotController.fetchSessions(instance, req.params.typebotId, req.query.remoteJid as string | undefined)
|
||||
});
|
||||
|
||||
res.status(HttpStatus.OK).json(response);
|
||||
|
Loading…
Reference in New Issue
Block a user