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