mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-14 09:51:24 -06:00
fix: connection state
This commit is contained in:
parent
f7293255cf
commit
f9abd90cc9
@ -3,6 +3,7 @@
|
|||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
* Fixed reconnect with pairing code or qrcode
|
* Fixed reconnect with pairing code or qrcode
|
||||||
|
* Fixed problem in createJid
|
||||||
|
|
||||||
# 1.4.0 (2023-07-24 17:03)
|
# 1.4.0 (2023-07-24 17:03)
|
||||||
|
|
||||||
|
@ -124,7 +124,6 @@ const optionsSchema: JSONSchema7 = {
|
|||||||
|
|
||||||
const numberDefinition: JSONSchema7Definition = {
|
const numberDefinition: JSONSchema7Definition = {
|
||||||
type: 'string',
|
type: 'string',
|
||||||
// pattern: '^\\d+[\\.@\\w-]+',
|
|
||||||
description: 'Invalid format',
|
description: 'Invalid format',
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -446,7 +445,6 @@ export const whatsappNumberSchema: JSONSchema7 = {
|
|||||||
uniqueItems: true,
|
uniqueItems: true,
|
||||||
items: {
|
items: {
|
||||||
type: 'string',
|
type: 'string',
|
||||||
// pattern: '^\\d+',
|
|
||||||
description: '"numbers" must be an array of numeric strings',
|
description: '"numbers" must be an array of numeric strings',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -245,7 +245,12 @@ export class InstanceController {
|
|||||||
|
|
||||||
public async connectionState({ instanceName }: InstanceDto) {
|
public async connectionState({ instanceName }: InstanceDto) {
|
||||||
this.logger.verbose('requested connectionState from ' + instanceName + ' instance');
|
this.logger.verbose('requested connectionState from ' + instanceName + ' instance');
|
||||||
return this.waMonitor.waInstances[instanceName]?.connectionStatus;
|
return {
|
||||||
|
instance: {
|
||||||
|
instanceName: instanceName,
|
||||||
|
state: this.waMonitor.waInstances[instanceName]?.connectionStatus?.state,
|
||||||
|
},
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public async fetchInstances({ instanceName }: InstanceDto) {
|
public async fetchInstances({ instanceName }: InstanceDto) {
|
||||||
@ -260,9 +265,9 @@ export class InstanceController {
|
|||||||
|
|
||||||
public async logout({ instanceName }: InstanceDto) {
|
public async logout({ instanceName }: InstanceDto) {
|
||||||
this.logger.verbose('requested logout from ' + instanceName + ' instance');
|
this.logger.verbose('requested logout from ' + instanceName + ' instance');
|
||||||
const stateConn = await this.connectionState({ instanceName });
|
const { instance } = await this.connectionState({ instanceName });
|
||||||
|
|
||||||
if (stateConn.state === 'close') {
|
if (instance.state === 'close') {
|
||||||
throw new BadRequestException(
|
throw new BadRequestException(
|
||||||
'The "' + instanceName + '" instance is not connected',
|
'The "' + instanceName + '" instance is not connected',
|
||||||
);
|
);
|
||||||
@ -285,15 +290,15 @@ export class InstanceController {
|
|||||||
|
|
||||||
public async deleteInstance({ instanceName }: InstanceDto) {
|
public async deleteInstance({ instanceName }: InstanceDto) {
|
||||||
this.logger.verbose('requested deleteInstance from ' + instanceName + ' instance');
|
this.logger.verbose('requested deleteInstance from ' + instanceName + ' instance');
|
||||||
const stateConn = await this.connectionState({ instanceName });
|
const { instance } = await this.connectionState({ instanceName });
|
||||||
|
|
||||||
if (stateConn.state === 'open') {
|
if (instance.state === 'open') {
|
||||||
throw new BadRequestException(
|
throw new BadRequestException(
|
||||||
'The "' + instanceName + '" instance needs to be disconnected',
|
'The "' + instanceName + '" instance needs to be disconnected',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if (stateConn.state === 'connecting') {
|
if (instance.state === 'connecting') {
|
||||||
this.logger.verbose('logging out instance: ' + instanceName);
|
this.logger.verbose('logging out instance: ' + instanceName);
|
||||||
|
|
||||||
await this.logout({ instanceName });
|
await this.logout({ instanceName });
|
||||||
|
@ -1517,7 +1517,7 @@ export class WAStartupService {
|
|||||||
.split(/\:/)[0]
|
.split(/\:/)[0]
|
||||||
.split('@')[0];
|
.split('@')[0];
|
||||||
|
|
||||||
if (number.includes('-') && number.length >= 24) {
|
if (number.length >= 18) {
|
||||||
this.logger.verbose('Jid created is group: ' + `${number}@g.us`);
|
this.logger.verbose('Jid created is group: ' + `${number}@g.us`);
|
||||||
number = number.replace(/[^\d-]/g, '');
|
number = number.replace(/[^\d-]/g, '');
|
||||||
return `${number}@g.us`;
|
return `${number}@g.us`;
|
||||||
|
Loading…
Reference in New Issue
Block a user