fix: update description on chatbots

This commit is contained in:
Davidson Gomes 2024-08-24 14:36:00 -03:00
parent d7049e798c
commit e8fa952de5
6 changed files with 13 additions and 8 deletions

View File

@ -332,6 +332,7 @@ export class DifyController extends ChatbotController implements ChatbotControll
}, },
data: { data: {
enabled: data?.enabled, enabled: data?.enabled,
description: data.description,
botType: data.botType, botType: data.botType,
apiUrl: data.apiUrl, apiUrl: data.apiUrl,
apiKey: data.apiKey, apiKey: data.apiKey,

View File

@ -319,6 +319,7 @@ export class FlowiseController extends ChatbotController implements ChatbotContr
}, },
data: { data: {
enabled: data?.enabled, enabled: data?.enabled,
description: data.description,
apiUrl: data.apiUrl, apiUrl: data.apiUrl,
apiKey: data.apiKey, apiKey: data.apiKey,
expire: data.expire, expire: data.expire,

View File

@ -319,6 +319,7 @@ export class GenericController extends ChatbotController implements ChatbotContr
}, },
data: { data: {
enabled: data?.enabled, enabled: data?.enabled,
description: data.description,
apiUrl: data.apiUrl, apiUrl: data.apiUrl,
apiKey: data.apiKey, apiKey: data.apiKey,
expire: data.expire, expire: data.expire,

View File

@ -523,6 +523,7 @@ export class OpenaiController extends ChatbotController implements ChatbotContro
}, },
data: { data: {
enabled: data?.enabled, enabled: data?.enabled,
description: data.description,
openaiCredsId: data.openaiCredsId, openaiCredsId: data.openaiCredsId,
botType: data.botType, botType: data.botType,
assistantId: data.assistantId, assistantId: data.assistantId,

View File

@ -335,6 +335,7 @@ export class TypebotController extends ChatbotController implements ChatbotContr
}, },
data: { data: {
enabled: data?.enabled, enabled: data?.enabled,
description: data.description,
url: data.url, url: data.url,
typebot: data.typebot, typebot: data.typebot,
expire: data.expire, expire: data.expire,

View File

@ -63,14 +63,14 @@ export class WebhookController extends EventController implements EventControlle
apiKey, apiKey,
local, local,
}: EmitData): Promise<void> { }: EmitData): Promise<void> {
const instance = (await this.get(instanceName)) as EventDto; const instance = (await this.get(instanceName)) as wa.LocalWebHook;
if (!instance || !instance.webhook?.enabled) { if (!instance || !instance?.enabled) {
return; return;
} }
const webhookConfig = configService.get<Webhook>('WEBHOOK'); const webhookConfig = configService.get<Webhook>('WEBHOOK');
const webhookLocal = instance.webhook?.events; const webhookLocal = instance?.events;
const we = event.replace(/[.-]/gm, '_').toUpperCase(); const we = event.replace(/[.-]/gm, '_').toUpperCase();
const transformedWe = we.replace(/_/gm, '-').toLowerCase(); const transformedWe = we.replace(/_/gm, '-').toLowerCase();
const enabledLog = configService.get<Log>('LOG').LEVEL.includes('WEBHOOKS'); const enabledLog = configService.get<Log>('LOG').LEVEL.includes('WEBHOOKS');
@ -79,7 +79,7 @@ export class WebhookController extends EventController implements EventControlle
event, event,
instance: instanceName, instance: instanceName,
data, data,
destination: instance.webhook?.url, destination: instance?.url,
date_time: dateTime, date_time: dateTime,
sender, sender,
server_url: serverUrl, server_url: serverUrl,
@ -90,10 +90,10 @@ export class WebhookController extends EventController implements EventControlle
if (Array.isArray(webhookLocal) && webhookLocal.includes(we)) { if (Array.isArray(webhookLocal) && webhookLocal.includes(we)) {
let baseURL: string; let baseURL: string;
if (instance.webhook?.byEvents) { if (instance?.webhookByEvents) {
baseURL = `${instance.webhook?.url}/${transformedWe}`; baseURL = `${instance?.url}/${transformedWe}`;
} else { } else {
baseURL = instance.webhook?.url; baseURL = instance?.url;
} }
if (enabledLog) { if (enabledLog) {
@ -107,7 +107,7 @@ export class WebhookController extends EventController implements EventControlle
} }
try { try {
if (instance.webhook?.enabled && isURL(instance.webhook.url, { require_tld: false })) { if (instance?.enabled && isURL(instance.url, { require_tld: false })) {
const httpService = axios.create({ baseURL }); const httpService = axios.create({ baseURL });
await httpService.post('', webhookData); await httpService.post('', webhookData);