fix: Adjusts in number validation for AR and MX numbers

This commit is contained in:
Davidson Gomes 2023-07-12 11:15:45 -03:00
parent 19e7c0be0b
commit 95045db74e
5 changed files with 42 additions and 11 deletions

View File

@ -1,3 +1,10 @@
# 1.1.6 (homolog)
### Fixed
* Adjusts in docker-compose files
* Adjusts in number validation for AR and MX numbers
# 1.1.5 (2023-07-12 07:17)
### Fixed

View File

@ -9,14 +9,16 @@ services:
container_name: mongodb
image: mongo
restart: always
volumes:
- evolution_mongodb_data:/data/db
- evolution_mongodb_configdb:/data/configdb
ports:
- 27017:27017
environment:
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: root
- MONGO_INITDB_ROOT_USERNAME=root
- MONGO_INITDB_ROOT_PASSWORD=root
- PUID=1000
- PGID=1000
volumes:
- evolution_mongodb_data:/data/db
- evolution_mongodb_configdb:/data/configdb
networks:
- evolution-net
expose:

View File

@ -8,6 +8,16 @@ services:
redis:
image: redis:latest
container_name: redis
command: >
redis-server
--port 6379
--appendonly yes
--save 900 1
--save 300 10
--save 60 10000
--appendfsync everysec
volumes:
- evolution_redis:/data
ports:
- 6379:6379
networks:

View File

@ -1,6 +1,6 @@
{
"name": "evolution-api",
"version": "1.1.4",
"version": "1.1.6",
"description": "Rest api for communication with WhatsApp",
"main": "./dist/src/main.js",
"scripts": {
@ -43,7 +43,7 @@
"@adiwajshing/keyed-db": "^0.2.4",
"@ffmpeg-installer/ffmpeg": "^1.1.0",
"@hapi/boom": "^10.0.1",
"@whiskeysockets/baileys": "github:EvolutionAPI/Baileys",
"@whiskeysockets/baileys": "github:vphelipe/WhiskeySockets-Baileys#master",
"axios": "^1.3.5",
"class-validator": "^0.13.2",
"compression": "^1.7.4",

View File

@ -1160,6 +1160,8 @@ export class WAStartupService {
}
return match[1] === '52' ? '52' + match[3] : '54' + match[3];
}
return jid;
}
return jid;
}
@ -1177,12 +1179,14 @@ export class WAStartupService {
}
return match[1] + match[2] + match[3];
}
return jid;
} else {
return jid;
}
}
private createJid(number: string): string {
console.log(number);
this.logger.verbose('Creating jid with number: ' + number);
if (number.includes('@g.us') || number.includes('@s.whatsapp.net')) {
this.logger.verbose('Number already contains @g.us or @s.whatsapp.net');
@ -1203,6 +1207,8 @@ export class WAStartupService {
}
const formattedMXARNumber = this.formatMXOrARNumber(number);
console.log(formattedMXARNumber, number);
if (formattedMXARNumber !== number) {
this.logger.verbose(
'Jid created is whatsapp in format MXAR: ' +
@ -1951,16 +1957,22 @@ export class WAStartupService {
const onWhatsapp: OnWhatsAppDto[] = [];
for await (const number of data.numbers) {
console.log('number', number);
const jid = this.createJid(number);
console.log('jid', jid);
if (isJidGroup(jid)) {
const group = await this.findGroup({ groupJid: jid }, 'inner');
onWhatsapp.push(new OnWhatsAppDto(group.id, !!group?.id, group?.subject));
} else {
try {
const result = (await this.client.onWhatsApp(jid))[0];
const verify = await this.client.onWhatsApp(jid);
const result = verify[0];
if (!result) {
onWhatsapp.push(new OnWhatsAppDto(jid, false));
} else {
console.log('onWhatsapp', result);
onWhatsapp.push(new OnWhatsAppDto(result.jid, result.exists));
} catch (error) {
onWhatsapp.push(new OnWhatsAppDto(number, false));
}
}
}