mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-12-23 21:57:45 -06:00
feat: evolution channel in instance create
This commit is contained in:
@@ -1,10 +1,13 @@
|
||||
import { InstanceDto } from '@api/dto/instance.dto';
|
||||
import { ProviderFiles } from '@api/provider/sessions';
|
||||
import { PrismaRepository } from '@api/repository/repository.service';
|
||||
import { CacheService } from '@api/services/cache.service';
|
||||
import { Integration } from '@api/types/wa.types';
|
||||
import { ConfigService } from '@config/env.config';
|
||||
import { BadRequestException } from '@exceptions';
|
||||
import EventEmitter2 from 'eventemitter2';
|
||||
|
||||
import { EvolutionStartupService } from './evolution/evolution.channel.service';
|
||||
import { BaileysStartupService } from './whatsapp/baileys/whatsapp.baileys.service';
|
||||
import { BusinessStartupService } from './whatsapp/business/whatsapp.business.service';
|
||||
|
||||
@@ -19,8 +22,12 @@ type ChannelDataType = {
|
||||
};
|
||||
|
||||
export class ChannelController {
|
||||
public init(integration: string, data: ChannelDataType) {
|
||||
if (integration === Integration.WHATSAPP_BUSINESS) {
|
||||
public init(instanceData: InstanceDto, data: ChannelDataType) {
|
||||
if (!instanceData.token && instanceData.integration === Integration.WHATSAPP_BUSINESS) {
|
||||
throw new BadRequestException('token is required');
|
||||
}
|
||||
|
||||
if (instanceData.integration === Integration.WHATSAPP_BUSINESS) {
|
||||
return new BusinessStartupService(
|
||||
data.configService,
|
||||
data.eventEmitter,
|
||||
@@ -32,6 +39,18 @@ export class ChannelController {
|
||||
);
|
||||
}
|
||||
|
||||
if (instanceData.integration === Integration.EVOLUTION) {
|
||||
return new EvolutionStartupService(
|
||||
data.configService,
|
||||
data.eventEmitter,
|
||||
data.prismaRepository,
|
||||
data.cache,
|
||||
data.chatwootCache,
|
||||
data.baileysCache,
|
||||
data.providerFiles,
|
||||
);
|
||||
}
|
||||
|
||||
return new BaileysStartupService(
|
||||
data.configService,
|
||||
data.eventEmitter,
|
||||
|
||||
Reference in New Issue
Block a user