mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-14 09:51:24 -06:00
fix: Adjusts in restart instance
This commit is contained in:
parent
7ed1965f57
commit
c6db03ffa2
@ -3,6 +3,7 @@
|
||||
### Fixed
|
||||
|
||||
* BusinessId added on create instances in manager
|
||||
* Adjusts in restart instance
|
||||
|
||||
# 2.0.6-rc (2024-08-02 19:23)
|
||||
|
||||
|
@ -583,6 +583,7 @@ export class InstanceController {
|
||||
};
|
||||
} catch (error) {
|
||||
this.logger.error(error);
|
||||
return { error: true, message: error.toString() };
|
||||
}
|
||||
}
|
||||
|
||||
@ -591,19 +592,26 @@ export class InstanceController {
|
||||
const instance = this.waMonitor.waInstances[instanceName];
|
||||
const state = instance?.connectionStatus?.state;
|
||||
|
||||
switch (state) {
|
||||
case 'open':
|
||||
if (this.configService.get<Chatwoot>('CHATWOOT').ENABLED) instance.clearCacheChatwoot();
|
||||
if (!state) {
|
||||
throw new BadRequestException('The "' + instanceName + '" instance does not exist');
|
||||
}
|
||||
|
||||
this.logger.info('Connection closed, restarting instance' + instanceName);
|
||||
instance.client?.ws?.close();
|
||||
instance.client?.end(new Error('restart'));
|
||||
return await this.connectToWhatsapp({ instanceName });
|
||||
default:
|
||||
return await this.connectionState({ instanceName });
|
||||
if (state == 'close') {
|
||||
throw new BadRequestException('The "' + instanceName + '" instance is not connected');
|
||||
} else if (state == 'open') {
|
||||
if (this.configService.get<Chatwoot>('CHATWOOT').ENABLED) instance.clearCacheChatwoot();
|
||||
this.logger.info('restarting instance' + instanceName);
|
||||
|
||||
instance.client?.ws?.close();
|
||||
instance.client?.end(new Error('restart'));
|
||||
return await this.connectToWhatsapp({ instanceName });
|
||||
} else if (state == 'connecting') {
|
||||
instance.client?.end(new Error('restart'));
|
||||
return await this.connectToWhatsapp({ instanceName });
|
||||
}
|
||||
} catch (error) {
|
||||
this.logger.error(error);
|
||||
return { error: true, message: error.toString() };
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user