mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-23 04:22:02 -06:00
refactor: integration folders
This commit is contained in:
parent
a08ca7a67d
commit
beafc62403
@ -150,18 +150,18 @@ export class InstanceController {
|
||||
},
|
||||
hash,
|
||||
webhook: {
|
||||
webhookUrl: instanceData.webhook.url,
|
||||
webhookByEvents: instanceData.webhook.byEvents,
|
||||
webhookBase64: instanceData.webhook.base64,
|
||||
webhookUrl: instanceData?.webhook?.url,
|
||||
webhookByEvents: instanceData?.webhook?.byEvents,
|
||||
webhookBase64: instanceData?.webhook?.base64,
|
||||
},
|
||||
websocket: {
|
||||
enabled: instanceData.websocket.enabled,
|
||||
enabled: instanceData?.websocket?.enabled,
|
||||
},
|
||||
rabbitmq: {
|
||||
enabled: instanceData.rabbitmq.enabled,
|
||||
enabled: instanceData?.rabbitmq?.enabled,
|
||||
},
|
||||
sqs: {
|
||||
enabled: instanceData.sqs.enabled,
|
||||
enabled: instanceData?.sqs?.enabled,
|
||||
},
|
||||
settings,
|
||||
qrcode: getQrcode,
|
||||
@ -237,18 +237,18 @@ export class InstanceController {
|
||||
},
|
||||
hash,
|
||||
webhook: {
|
||||
webhookUrl: instanceData.webhook.url,
|
||||
webhookByEvents: instanceData.webhook.byEvents,
|
||||
webhookBase64: instanceData.webhook.base64,
|
||||
webhookUrl: instanceData?.webhook?.url,
|
||||
webhookByEvents: instanceData?.webhook?.byEvents,
|
||||
webhookBase64: instanceData?.webhook?.base64,
|
||||
},
|
||||
websocket: {
|
||||
enabled: instanceData.websocket.enabled,
|
||||
enabled: instanceData?.websocket?.enabled,
|
||||
},
|
||||
rabbitmq: {
|
||||
enabled: instanceData.rabbitmq.enabled,
|
||||
enabled: instanceData?.rabbitmq?.enabled,
|
||||
},
|
||||
sqs: {
|
||||
enabled: instanceData.sqs.enabled,
|
||||
enabled: instanceData?.sqs?.enabled,
|
||||
},
|
||||
settings,
|
||||
chatwoot: {
|
||||
@ -269,6 +269,7 @@ export class InstanceController {
|
||||
},
|
||||
};
|
||||
} catch (error) {
|
||||
this.waMonitor.deleteInstance(instanceData.instanceName);
|
||||
this.logger.error(isArray(error.message) ? error.message[0] : error.message);
|
||||
throw new BadRequestException(isArray(error.message) ? error.message[0] : error.message);
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ import { InstanceDto } from '@api/dto/instance.dto';
|
||||
import { PrismaRepository } from '@api/repository/repository.service';
|
||||
import {
|
||||
difyController,
|
||||
eventManager,
|
||||
flowiseController,
|
||||
genericController,
|
||||
openaiController,
|
||||
@ -90,32 +89,17 @@ export class ChatbotController {
|
||||
pushName,
|
||||
isIntegration,
|
||||
};
|
||||
// generic
|
||||
await genericController.emit(emitData);
|
||||
|
||||
// typebot
|
||||
await typebotController.emit(emitData);
|
||||
|
||||
// openai
|
||||
await openaiController.emit(emitData);
|
||||
|
||||
// dify
|
||||
await difyController.emit(emitData);
|
||||
|
||||
// flowise
|
||||
await flowiseController.emit(emitData);
|
||||
}
|
||||
|
||||
public async setInstance(instanceName: string, data: InstanceDto): Promise<any> {
|
||||
if (data.websocket.enabled)
|
||||
await eventManager.websocket.set(instanceName, {
|
||||
websocket: {
|
||||
enabled: true,
|
||||
events: data.websocket.events,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
public processDebounce(
|
||||
userMessageDebounce: any,
|
||||
content: string,
|
||||
|
@ -8,11 +8,11 @@ import { Events } from '@api/types/wa.types';
|
||||
import { Auth, configService, HttpServer, Typebot } from '@config/env.config';
|
||||
import { Logger } from '@config/logger.config';
|
||||
import { BadRequestException } from '@exceptions';
|
||||
import { Typebot as TypebotModel } from '@prisma/client';
|
||||
import { getConversationMessage } from '@utils/getConversationMessage';
|
||||
import axios from 'axios';
|
||||
|
||||
import { ChatbotController, ChatbotControllerInterface } from '../../chatbot.controller';
|
||||
import { Typebot as TypebotModel } from '@prisma/client';
|
||||
|
||||
export class TypebotController extends ChatbotController implements ChatbotControllerInterface {
|
||||
constructor(
|
||||
|
@ -2,7 +2,7 @@ import { Constructor } from '@api/integrations/integration.dto';
|
||||
|
||||
export class EventDto {
|
||||
webhook?: {
|
||||
enabled: boolean;
|
||||
enabled?: boolean;
|
||||
events?: string[];
|
||||
url?: string;
|
||||
byEvents?: boolean;
|
||||
@ -10,17 +10,17 @@ export class EventDto {
|
||||
};
|
||||
|
||||
websocket?: {
|
||||
enabled: boolean;
|
||||
enabled?: boolean;
|
||||
events?: string[];
|
||||
};
|
||||
|
||||
sqs?: {
|
||||
enabled: boolean;
|
||||
enabled?: boolean;
|
||||
events?: string[];
|
||||
};
|
||||
|
||||
rabbitmq?: {
|
||||
enabled: boolean;
|
||||
enabled?: boolean;
|
||||
events?: string[];
|
||||
};
|
||||
}
|
||||
@ -28,7 +28,7 @@ export class EventDto {
|
||||
export function EventInstanceMixin<TBase extends Constructor>(Base: TBase) {
|
||||
return class extends Base {
|
||||
webhook?: {
|
||||
enabled: boolean;
|
||||
enabled?: boolean;
|
||||
events?: string[];
|
||||
url?: string;
|
||||
byEvents?: boolean;
|
||||
@ -36,17 +36,17 @@ export function EventInstanceMixin<TBase extends Constructor>(Base: TBase) {
|
||||
};
|
||||
|
||||
websocket?: {
|
||||
enabled: boolean;
|
||||
enabled?: boolean;
|
||||
events?: string[];
|
||||
};
|
||||
|
||||
sqs?: {
|
||||
enabled: boolean;
|
||||
enabled?: boolean;
|
||||
events?: string[];
|
||||
};
|
||||
|
||||
rabbitmq?: {
|
||||
enabled: boolean;
|
||||
enabled?: boolean;
|
||||
events?: string[];
|
||||
};
|
||||
};
|
||||
|
@ -96,35 +96,39 @@ export class EventManager {
|
||||
}
|
||||
|
||||
public async setInstance(instanceName: string, data: any): Promise<any> {
|
||||
await this.websocket.set(instanceName, {
|
||||
websocket: {
|
||||
enabled: data.websocket?.enabled,
|
||||
events: data.websocket?.events,
|
||||
},
|
||||
});
|
||||
if (data.websocket)
|
||||
await this.websocket.set(instanceName, {
|
||||
websocket: {
|
||||
enabled: data.websocket?.enabled,
|
||||
events: data.websocket?.events,
|
||||
},
|
||||
});
|
||||
|
||||
await this.rabbitmq.set(instanceName, {
|
||||
rabbitmq: {
|
||||
enabled: data.rabbitmq?.enabled,
|
||||
events: data.rabbitmq?.events,
|
||||
},
|
||||
});
|
||||
if (data.rabbitmq)
|
||||
await this.rabbitmq.set(instanceName, {
|
||||
rabbitmq: {
|
||||
enabled: data.rabbitmq?.enabled,
|
||||
events: data.rabbitmq?.events,
|
||||
},
|
||||
});
|
||||
|
||||
await this.sqs.set(instanceName, {
|
||||
sqs: {
|
||||
enabled: data.sqs?.enabled,
|
||||
events: data.sqs?.events,
|
||||
},
|
||||
});
|
||||
if (data.sqs)
|
||||
await this.sqs.set(instanceName, {
|
||||
sqs: {
|
||||
enabled: data.sqs?.enabled,
|
||||
events: data.sqs?.events,
|
||||
},
|
||||
});
|
||||
|
||||
await this.webhook.set(instanceName, {
|
||||
webhook: {
|
||||
enabled: data.webhook?.enabled,
|
||||
events: data.webhook?.events,
|
||||
url: data.webhook.url,
|
||||
base64: data.webhook.base64,
|
||||
byEvents: data.webhook.byEvents,
|
||||
},
|
||||
});
|
||||
if (data.webhook)
|
||||
await this.webhook.set(instanceName, {
|
||||
webhook: {
|
||||
enabled: data.webhook?.enabled,
|
||||
events: data.webhook?.events,
|
||||
url: data.webhook?.url,
|
||||
base64: data.webhook?.base64,
|
||||
byEvents: data.webhook?.byEvents,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -207,6 +207,14 @@ export class WAMonitoringService {
|
||||
}
|
||||
}
|
||||
|
||||
public deleteInstance(instanceName: string) {
|
||||
try {
|
||||
this.eventEmitter.emit('remove.instance', instanceName, 'inner');
|
||||
} catch (error) {
|
||||
this.logger.error(error);
|
||||
}
|
||||
}
|
||||
|
||||
private async setInstance(instanceData: InstanceDto) {
|
||||
const instance = channelController.init(instanceData, {
|
||||
configService: this.configService,
|
||||
|
@ -427,7 +427,7 @@ export class ConfigService {
|
||||
ENABLED: process.env?.CHATWOOT_ENABLED === 'true',
|
||||
MESSAGE_DELETE: process.env.CHATWOOT_MESSAGE_DELETE === 'true',
|
||||
MESSAGE_READ: process.env.CHATWOOT_MESSAGE_READ === 'true',
|
||||
BOT_CONTACT: process.env.CHATWOOT_BOT_CONTACT === 'true',
|
||||
BOT_CONTACT: !process.env.CHATWOOT_BOT_CONTACT || process.env.CHATWOOT_BOT_CONTACT === 'true',
|
||||
IMPORT: {
|
||||
DATABASE: {
|
||||
CONNECTION: {
|
||||
|
Loading…
Reference in New Issue
Block a user