Compare commits

..

5 Commits
1.4.0 ... 1.4.1

Author SHA1 Message Date
Davidson Gomes
cc91f2e5db Merge branch 'release/1.4.1' 2023-07-24 18:28:45 -03:00
Davidson Gomes
8d1f2313ac version: 1.4.1 2023-07-24 18:28:39 -03:00
Davidson Gomes
f9abd90cc9 fix: connection state 2023-07-24 18:28:01 -03:00
Davidson Gomes
f7293255cf fix: Fixed reconnect with pairing code or qrcode 2023-07-24 18:21:11 -03:00
Davidson Gomes
7d6a130cf9 Merge tag '1.4.0' into develop
* Added connection functionality via pairing code
* Added fetch profile endpoint in chat controller
* Created settings controller
* Added reject call and send text message when receiving a call
* Added setting to ignore group messages
* Added connection with pairing code in chatwoot with command /init:{NUMBER}
* Added encoding option in endpoint sendWhatsAppAudio

* Added link preview option in send text message
* Fixed problem with fileSha256 appearing when sending a sticker in chatwoot
* Fixed issue where it was not possible to open a conversation when sent at first by me on my cell phone in chatwoot
* Now it only updates the contact name if it is the same as the phone number in chatwoot
* Now accepts all chatwoot inbox templates
* Command to create new instances set to /new_instance:{NAME}:{NUMBER}
* Fix in chatwoot set, sign msg can now be disabled

- Chatwoot: v2.18.0 - v3.0.0 (Beta)
2023-07-24 17:05:43 -03:00
5 changed files with 25 additions and 19 deletions

View File

@@ -1,3 +1,10 @@
# 1.4.1 (2023-07-24 18:28)
### Fixed
* Fixed reconnect with pairing code or qrcode
* Fixed problem in createJid
# 1.4.0 (2023-07-24 17:03)
### Features

View File

@@ -1,6 +1,6 @@
{
"name": "evolution-api",
"version": "1.4.0",
"version": "1.4.1",
"description": "Rest api for communication with WhatsApp",
"main": "./dist/src/main.js",
"scripts": {

View File

@@ -124,7 +124,6 @@ const optionsSchema: JSONSchema7 = {
const numberDefinition: JSONSchema7Definition = {
type: 'string',
// pattern: '^\\d+[\\.@\\w-]+',
description: 'Invalid format',
};
@@ -446,7 +445,6 @@ export const whatsappNumberSchema: JSONSchema7 = {
uniqueItems: true,
items: {
type: 'string',
// pattern: '^\\d+',
description: '"numbers" must be an array of numeric strings',
},
},

View File

@@ -107,7 +107,7 @@ export class InstanceController {
if (qrcode) {
this.logger.verbose('creating qrcode');
await instance.connectToWhatsapp(number);
await delay(3000);
await delay(5000);
getQrcode = instance.qrCode;
}
@@ -214,7 +214,7 @@ export class InstanceController {
this.logger.verbose('connecting');
await instance.connectToWhatsapp(number);
await delay(2000);
await delay(5000);
return instance.qrCode;
}
@@ -245,7 +245,12 @@ export class InstanceController {
public async connectionState({ instanceName }: InstanceDto) {
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) {
@@ -260,9 +265,9 @@ export class InstanceController {
public async logout({ instanceName }: InstanceDto) {
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(
'The "' + instanceName + '" instance is not connected',
);
@@ -285,15 +290,15 @@ export class InstanceController {
public async deleteInstance({ instanceName }: InstanceDto) {
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(
'The "' + instanceName + '" instance needs to be disconnected',
);
}
try {
if (stateConn.state === 'connecting') {
if (instance.state === 'connecting') {
this.logger.verbose('logging out instance: ' + instanceName);
await this.logout({ instanceName });

View File

@@ -606,11 +606,14 @@ export class WAStartupService {
color: { light: '#ffffff', dark: '#198754' },
};
console.log(this.phoneNumber);
if (this.phoneNumber) {
await delay(2000);
this.instance.qrcode.pairingCode = await this.client.requestPairingCode(
this.phoneNumber,
);
} else {
this.instance.qrcode.pairingCode = null;
}
this.logger.verbose('Generating QR code');
@@ -894,13 +897,6 @@ export class WAStartupService {
this.phoneNumber = number;
// if (number) {
// this.logger.verbose('creating pairing code');
// await delay(5000);
// this.phoneNumber = number;
// this.instance.qrcode.pairingCode = await this.client.requestPairingCode(number);
// }
return this.client;
} catch (error) {
this.logger.error(error);
@@ -1521,7 +1517,7 @@ export class WAStartupService {
.split(/\:/)[0]
.split('@')[0];
if (number.includes('-') && number.length >= 24) {
if (number.length >= 18) {
this.logger.verbose('Jid created is group: ' + `${number}@g.us`);
number = number.replace(/[^\d-]/g, '');
return `${number}@g.us`;