Skip to content

Commit cc91f2e

Browse files
committed
Merge branch 'release/1.4.1'
2 parents be7bb2e + 8d1f231 commit cc91f2e

File tree

5 files changed

+25
-19
lines changed

5 files changed

+25
-19
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# 1.4.1 (2023-07-24 18:28)
2+
3+
### Fixed
4+
5+
* Fixed reconnect with pairing code or qrcode
6+
* Fixed problem in createJid
7+
18
# 1.4.0 (2023-07-24 17:03)
29

310
### Features

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "evolution-api",
3-
"version": "1.4.0",
3+
"version": "1.4.1",
44
"description": "Rest api for communication with WhatsApp",
55
"main": "./dist/src/main.js",
66
"scripts": {

src/validate/validate.schema.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ const optionsSchema: JSONSchema7 = {
124124

125125
const numberDefinition: JSONSchema7Definition = {
126126
type: 'string',
127-
// pattern: '^\\d+[\\.@\\w-]+',
128127
description: 'Invalid format',
129128
};
130129

@@ -446,7 +445,6 @@ export const whatsappNumberSchema: JSONSchema7 = {
446445
uniqueItems: true,
447446
items: {
448447
type: 'string',
449-
// pattern: '^\\d+',
450448
description: '"numbers" must be an array of numeric strings',
451449
},
452450
},

src/whatsapp/controllers/instance.controller.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ export class InstanceController {
107107
if (qrcode) {
108108
this.logger.verbose('creating qrcode');
109109
await instance.connectToWhatsapp(number);
110-
await delay(3000);
110+
await delay(5000);
111111
getQrcode = instance.qrCode;
112112
}
113113

@@ -214,7 +214,7 @@ export class InstanceController {
214214
this.logger.verbose('connecting');
215215
await instance.connectToWhatsapp(number);
216216

217-
await delay(2000);
217+
await delay(5000);
218218
return instance.qrCode;
219219
}
220220

@@ -245,7 +245,12 @@ export class InstanceController {
245245

246246
public async connectionState({ instanceName }: InstanceDto) {
247247
this.logger.verbose('requested connectionState from ' + instanceName + ' instance');
248-
return this.waMonitor.waInstances[instanceName]?.connectionStatus;
248+
return {
249+
instance: {
250+
instanceName: instanceName,
251+
state: this.waMonitor.waInstances[instanceName]?.connectionStatus?.state,
252+
},
253+
};
249254
}
250255

251256
public async fetchInstances({ instanceName }: InstanceDto) {
@@ -260,9 +265,9 @@ export class InstanceController {
260265

261266
public async logout({ instanceName }: InstanceDto) {
262267
this.logger.verbose('requested logout from ' + instanceName + ' instance');
263-
const stateConn = await this.connectionState({ instanceName });
268+
const { instance } = await this.connectionState({ instanceName });
264269

265-
if (stateConn.state === 'close') {
270+
if (instance.state === 'close') {
266271
throw new BadRequestException(
267272
'The "' + instanceName + '" instance is not connected',
268273
);
@@ -285,15 +290,15 @@ export class InstanceController {
285290

286291
public async deleteInstance({ instanceName }: InstanceDto) {
287292
this.logger.verbose('requested deleteInstance from ' + instanceName + ' instance');
288-
const stateConn = await this.connectionState({ instanceName });
293+
const { instance } = await this.connectionState({ instanceName });
289294

290-
if (stateConn.state === 'open') {
295+
if (instance.state === 'open') {
291296
throw new BadRequestException(
292297
'The "' + instanceName + '" instance needs to be disconnected',
293298
);
294299
}
295300
try {
296-
if (stateConn.state === 'connecting') {
301+
if (instance.state === 'connecting') {
297302
this.logger.verbose('logging out instance: ' + instanceName);
298303

299304
await this.logout({ instanceName });

src/whatsapp/services/whatsapp.service.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -606,11 +606,14 @@ export class WAStartupService {
606606
color: { light: '#ffffff', dark: '#198754' },
607607
};
608608

609+
console.log(this.phoneNumber);
609610
if (this.phoneNumber) {
610611
await delay(2000);
611612
this.instance.qrcode.pairingCode = await this.client.requestPairingCode(
612613
this.phoneNumber,
613614
);
615+
} else {
616+
this.instance.qrcode.pairingCode = null;
614617
}
615618

616619
this.logger.verbose('Generating QR code');
@@ -894,13 +897,6 @@ export class WAStartupService {
894897

895898
this.phoneNumber = number;
896899

897-
// if (number) {
898-
// this.logger.verbose('creating pairing code');
899-
// await delay(5000);
900-
// this.phoneNumber = number;
901-
// this.instance.qrcode.pairingCode = await this.client.requestPairingCode(number);
902-
// }
903-
904900
return this.client;
905901
} catch (error) {
906902
this.logger.error(error);
@@ -1521,7 +1517,7 @@ export class WAStartupService {
15211517
.split(/\:/)[0]
15221518
.split('@')[0];
15231519

1524-
if (number.includes('-') && number.length >= 24) {
1520+
if (number.length >= 18) {
15251521
this.logger.verbose('Jid created is group: ' + `${number}@g.us`);
15261522
number = number.replace(/[^\d-]/g, '');
15271523
return `${number}@g.us`;

0 commit comments

Comments
 (0)