mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-14 01:41:24 -06:00
fix: adjusts for new manager
This commit is contained in:
parent
089810fb55
commit
2a7f9698d2
@ -0,0 +1,20 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- The values [open] on the enum `TypebotSessionStatus` will be removed. If these variants are still used in the database, this will fail.
|
||||
- Changed the type of `status` on the `TypebotSession` table. No cast exists, the column would be dropped and recreated, which cannot be done if there is data, since the column is required.
|
||||
|
||||
*/
|
||||
-- AlterEnum
|
||||
BEGIN;
|
||||
CREATE TYPE "TypebotSessionStatus_new" AS ENUM ('opened', 'closed', 'paused');
|
||||
ALTER TABLE "TypebotSession" ALTER COLUMN "status" TYPE "TypebotSessionStatus_new" USING ("status"::text::"TypebotSessionStatus_new");
|
||||
ALTER TABLE "OpenaiSession" ALTER COLUMN "status" TYPE "TypebotSessionStatus_new" USING ("status"::text::"TypebotSessionStatus_new");
|
||||
ALTER TYPE "TypebotSessionStatus" RENAME TO "TypebotSessionStatus_old";
|
||||
ALTER TYPE "TypebotSessionStatus_new" RENAME TO "TypebotSessionStatus";
|
||||
DROP TYPE "TypebotSessionStatus_old";
|
||||
COMMIT;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "TypebotSession" DROP COLUMN "status",
|
||||
ADD COLUMN "status" "TypebotSessionStatus" NOT NULL;
|
@ -36,6 +36,7 @@ enum TypebotSessionStatus {
|
||||
enum TriggerType {
|
||||
all
|
||||
keyword
|
||||
none
|
||||
}
|
||||
|
||||
enum TriggerOperator {
|
||||
|
@ -28,7 +28,7 @@ enum DeviceMessage {
|
||||
}
|
||||
|
||||
enum TypebotSessionStatus {
|
||||
open
|
||||
opened
|
||||
closed
|
||||
paused
|
||||
}
|
||||
@ -292,7 +292,7 @@ model TypebotSession {
|
||||
remoteJid String @db.VarChar(100)
|
||||
pushName String? @db.VarChar(100)
|
||||
sessionId String @db.VarChar(100)
|
||||
status String @db.VarChar(100)
|
||||
status TypebotSessionStatus
|
||||
prefilledVariables Json? @db.JsonB
|
||||
awaitUser Boolean @default(false) @db.Boolean
|
||||
createdAt DateTime? @default(now()) @db.Timestamp
|
||||
|
@ -371,7 +371,7 @@ export class OpenaiService {
|
||||
throw new Error('Openai Bot already exists');
|
||||
}
|
||||
|
||||
if (data.triggerType !== 'all') {
|
||||
if (data.triggerType === 'keyword') {
|
||||
if (!data.triggerOperator || !data.triggerValue) {
|
||||
throw new Error('Trigger operator and value are required');
|
||||
}
|
||||
@ -449,7 +449,6 @@ export class OpenaiService {
|
||||
});
|
||||
|
||||
if (!openaiBots.length) {
|
||||
this.logger.error('Openai bot not found');
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -618,7 +617,7 @@ export class OpenaiService {
|
||||
stopBotFromMe: settings.stopBotFromMe,
|
||||
keepOpen: settings.keepOpen,
|
||||
ignoreJids: settings.ignoreJids,
|
||||
openaiIdFallback: settings.Fallback,
|
||||
openaiIdFallback: settings.openaiIdFallback,
|
||||
fallback: settings.Fallback,
|
||||
};
|
||||
} catch (error) {
|
||||
@ -1152,7 +1151,7 @@ export class OpenaiService {
|
||||
data: {
|
||||
remoteJid: data.remoteJid,
|
||||
sessionId: threadId,
|
||||
status: 'open',
|
||||
status: 'opened',
|
||||
awaitUser: false,
|
||||
openaiBotId: data.openaiBotId,
|
||||
instanceId: instance.instanceId,
|
||||
@ -1217,7 +1216,7 @@ export class OpenaiService {
|
||||
id: session.id,
|
||||
},
|
||||
data: {
|
||||
status: 'open',
|
||||
status: 'opened',
|
||||
awaitUser: true,
|
||||
},
|
||||
});
|
||||
@ -1255,7 +1254,7 @@ export class OpenaiService {
|
||||
settings: OpenaiSetting,
|
||||
content: string,
|
||||
) {
|
||||
if (session && session.status !== 'open') {
|
||||
if (session && session.status !== 'opened') {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1291,7 +1290,7 @@ export class OpenaiService {
|
||||
id: session.id,
|
||||
},
|
||||
data: {
|
||||
status: 'open',
|
||||
status: 'opened',
|
||||
awaitUser: false,
|
||||
},
|
||||
});
|
||||
@ -1369,7 +1368,7 @@ export class OpenaiService {
|
||||
id: session.id,
|
||||
},
|
||||
data: {
|
||||
status: 'open',
|
||||
status: 'opened',
|
||||
awaitUser: true,
|
||||
},
|
||||
});
|
||||
@ -1397,7 +1396,7 @@ export class OpenaiService {
|
||||
data: {
|
||||
remoteJid: data.remoteJid,
|
||||
sessionId: id,
|
||||
status: 'open',
|
||||
status: 'opened',
|
||||
awaitUser: false,
|
||||
openaiBotId: data.openaiBotId,
|
||||
instanceId: instance.instanceId,
|
||||
@ -1497,7 +1496,7 @@ export class OpenaiService {
|
||||
id: session.id,
|
||||
},
|
||||
data: {
|
||||
status: 'open',
|
||||
status: 'opened',
|
||||
awaitUser: true,
|
||||
},
|
||||
});
|
||||
@ -1515,7 +1514,7 @@ export class OpenaiService {
|
||||
settings: OpenaiSetting,
|
||||
content: string,
|
||||
) {
|
||||
if (session && session.status !== 'open') {
|
||||
if (session && session.status !== 'opened') {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1551,7 +1550,7 @@ export class OpenaiService {
|
||||
id: session.id,
|
||||
},
|
||||
data: {
|
||||
status: 'open',
|
||||
status: 'opened',
|
||||
awaitUser: false,
|
||||
},
|
||||
});
|
||||
@ -1659,7 +1658,7 @@ export class OpenaiService {
|
||||
id: session.id,
|
||||
},
|
||||
data: {
|
||||
status: 'open',
|
||||
status: 'opened',
|
||||
awaitUser: true,
|
||||
},
|
||||
});
|
||||
|
@ -33,8 +33,8 @@ export const openaiSchema: JSONSchema7 = {
|
||||
assistantMessages: { type: 'array', items: { type: 'string' } },
|
||||
userMessages: { type: 'array', items: { type: 'string' } },
|
||||
maxTokens: { type: 'integer' },
|
||||
triggerType: { type: 'string', enum: ['all', 'keyword'] },
|
||||
triggerOperator: { type: 'string', enum: ['equals', 'contains', 'startsWith', 'endsWith', 'regex', 'none'] },
|
||||
triggerType: { type: 'string', enum: ['all', 'keyword', 'none'] },
|
||||
triggerOperator: { type: 'string', enum: ['equals', 'contains', 'startsWith', 'endsWith', 'regex'] },
|
||||
triggerValue: { type: 'string' },
|
||||
expire: { type: 'integer' },
|
||||
keywordFinish: { type: 'string' },
|
||||
|
@ -229,7 +229,7 @@ export class TypebotService {
|
||||
throw new Error('Typebot already exists');
|
||||
}
|
||||
|
||||
if (data.triggerType !== 'all') {
|
||||
if (data.triggerType === 'keyword') {
|
||||
if (!data.triggerOperator || !data.triggerValue) {
|
||||
throw new Error('Trigger operator and value are required');
|
||||
}
|
||||
@ -300,7 +300,6 @@ export class TypebotService {
|
||||
});
|
||||
|
||||
if (!typebots.length) {
|
||||
this.logger.error('Typebot not found');
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,7 @@ export const typebotSchema: JSONSchema7 = {
|
||||
enabled: { type: 'boolean' },
|
||||
url: { type: 'string' },
|
||||
typebot: { type: 'string' },
|
||||
triggerType: { type: 'string', enum: ['all', 'keyword'] },
|
||||
triggerType: { type: 'string', enum: ['all', 'keyword', 'none'] },
|
||||
triggerOperator: { type: 'string', enum: ['equals', 'contains', 'startsWith', 'endsWith', 'regex'] },
|
||||
triggerValue: { type: 'string' },
|
||||
expire: { type: 'integer' },
|
||||
|
Loading…
Reference in New Issue
Block a user