Revert "Fixes Typebot.start, fetchSessions and adds typebot composite key migration"

This reverts commit a6326861da.
This commit is contained in:
Júlio Paulillo 2024-09-04 15:19:27 -03:00
parent a6326861da
commit 586b703872
4 changed files with 3 additions and 15 deletions

View File

@ -1,8 +0,0 @@
/*
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");

View File

@ -311,8 +311,6 @@ model Typebot {
Instance Instance @relation(fields: [instanceId], references: [id], onDelete: Cascade) Instance Instance @relation(fields: [instanceId], references: [id], onDelete: Cascade)
instanceId String instanceId String
TypebotSetting TypebotSetting[] TypebotSetting TypebotSetting[]
@@unique([url, typebot, instanceId], name: "url_typebot_instanceId")
} }
model TypebotSetting { model TypebotSetting {

View File

@ -682,7 +682,7 @@ export class TypebotController extends ChatbotController implements ChatbotContr
stopBotFromMe: stopBotFromMe, stopBotFromMe: stopBotFromMe,
keepOpen: keepOpen, keepOpen: keepOpen,
prefilledVariables: prefilledVariables, prefilledVariables: prefilledVariables,
botId: findBot.id typebotId: findBot.id,
}); });
if (response.sessionId) { if (response.sessionId) {
@ -889,7 +889,7 @@ export class TypebotController extends ChatbotController implements ChatbotContr
throw new Error('Typebot not found'); throw new Error('Typebot not found');
} }
const sessions = await this.sessionRepository.findMany({ return await this.sessionRepository.findMany({
where: { where: {
instanceId: instanceId, instanceId: instanceId,
remoteJid, remoteJid,
@ -897,8 +897,6 @@ export class TypebotController extends ChatbotController implements ChatbotContr
type: 'typebot', type: 'typebot',
}, },
}); });
return sessions;
} catch (error) { } catch (error) {
this.logger.error(error); this.logger.error(error);
throw new Error('Error fetching sessions'); throw new Error('Error fetching sessions');

View File

@ -113,7 +113,7 @@ export class TypebotRouter extends RouterBroker {
request: req, request: req,
schema: instanceSchema, schema: instanceSchema,
ClassRef: InstanceDto, ClassRef: InstanceDto,
execute: (instance) => typebotController.fetchSessions(instance, req.params.typebotId, req.query.remoteJid as string | undefined) execute: (instance) => typebotController.fetchSessions(instance, req.params.typebotId),
}); });
res.status(HttpStatus.OK).json(response); res.status(HttpStatus.OK).json(response);