mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-12-20 04:12:23 -06:00
fix: chatwoot screen
This commit is contained in:
@@ -46,6 +46,10 @@ export class InstanceController {
|
||||
providerFiles: this.providerFiles,
|
||||
});
|
||||
|
||||
if (!instance) {
|
||||
throw new BadRequestException('Invalid integration');
|
||||
}
|
||||
|
||||
const instanceId = v4();
|
||||
|
||||
instanceData.instanceId = instanceId;
|
||||
@@ -62,6 +66,7 @@ export class InstanceController {
|
||||
hash,
|
||||
number: instanceData.number,
|
||||
businessId: instanceData.businessId,
|
||||
status: instanceData.status,
|
||||
});
|
||||
|
||||
instance.setInstance({
|
||||
@@ -146,7 +151,7 @@ export class InstanceController {
|
||||
integration: instanceData.integration,
|
||||
webhookWaBusiness,
|
||||
accessTokenWaBusiness,
|
||||
status: 'created',
|
||||
status: instance.connectionStatus.state,
|
||||
},
|
||||
hash,
|
||||
webhook: {
|
||||
@@ -233,7 +238,7 @@ export class InstanceController {
|
||||
integration: instanceData.integration,
|
||||
webhookWaBusiness,
|
||||
accessTokenWaBusiness,
|
||||
status: 'created',
|
||||
status: instance.connectionStatus.state,
|
||||
},
|
||||
hash,
|
||||
webhook: {
|
||||
|
||||
@@ -9,6 +9,7 @@ export class InstanceDto extends IntegrationDto {
|
||||
number?: string;
|
||||
integration?: string;
|
||||
token?: string;
|
||||
status?: string;
|
||||
// settings
|
||||
rejectCall?: boolean;
|
||||
msgCall?: string;
|
||||
|
||||
@@ -80,14 +80,18 @@ export class ChannelController {
|
||||
);
|
||||
}
|
||||
|
||||
return new BaileysStartupService(
|
||||
data.configService,
|
||||
data.eventEmitter,
|
||||
data.prismaRepository,
|
||||
data.cache,
|
||||
data.chatwootCache,
|
||||
data.baileysCache,
|
||||
data.providerFiles,
|
||||
);
|
||||
if (instanceData.integration === Integration.WHATSAPP_BAILEYS) {
|
||||
return new BaileysStartupService(
|
||||
data.configService,
|
||||
data.eventEmitter,
|
||||
data.prismaRepository,
|
||||
data.cache,
|
||||
data.chatwootCache,
|
||||
data.baileysCache,
|
||||
data.providerFiles,
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,13 +118,17 @@ export class WAMonitoringService {
|
||||
public async cleaningUp(instanceName: string) {
|
||||
let instanceDbId: string;
|
||||
if (this.db.SAVE_DATA.INSTANCE) {
|
||||
const findInstance = await this.prismaRepository.instance.findFirst({
|
||||
where: { name: instanceName },
|
||||
});
|
||||
|
||||
if (!findInstance) this.logger.error('Instance not found');
|
||||
|
||||
const instance = await this.prismaRepository.instance.update({
|
||||
where: { name: instanceName },
|
||||
data: { connectionStatus: 'close' },
|
||||
});
|
||||
|
||||
if (!instance) this.logger.error('Instance not found');
|
||||
|
||||
rmSync(join(INSTANCE_DIR, instance.id), { recursive: true, force: true });
|
||||
|
||||
instanceDbId = instance.id;
|
||||
@@ -150,6 +154,8 @@ export class WAMonitoringService {
|
||||
where: { name: instanceName },
|
||||
});
|
||||
|
||||
if (!instance) return;
|
||||
|
||||
rmSync(join(INSTANCE_DIR, instance.id), { recursive: true, force: true });
|
||||
|
||||
await this.prismaRepository.session.deleteMany({ where: { sessionId: instance.id } });
|
||||
@@ -194,7 +200,8 @@ export class WAMonitoringService {
|
||||
data: {
|
||||
id: data.instanceId,
|
||||
name: data.instanceName,
|
||||
connectionStatus: data.integration && data.integration === Integration.WHATSAPP_BAILEYS ? 'close' : 'open',
|
||||
connectionStatus:
|
||||
data.integration && data.integration === Integration.WHATSAPP_BAILEYS ? 'close' : data.status ?? 'open',
|
||||
number: data.number,
|
||||
integration: data.integration || Integration.WHATSAPP_BAILEYS,
|
||||
token: data.hash,
|
||||
@@ -226,6 +233,8 @@ export class WAMonitoringService {
|
||||
providerFiles: this.providerFiles,
|
||||
});
|
||||
|
||||
if (!instance) return;
|
||||
|
||||
instance.setInstance({
|
||||
instanceId: instanceData.instanceId,
|
||||
instanceName: instanceData.instanceName,
|
||||
|
||||
Reference in New Issue
Block a user