Skip to content

Commit 8caf3a0

Browse files
committed
Merge branch 'release/1.7.2'
2 parents 5975117 + 96ae976 commit 8caf3a0

File tree

134 files changed

+1061
-603
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

134 files changed

+1061
-603
lines changed

CHANGELOG.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
# 1.7.2 (2024-04-12 17:31)
2+
3+
### Feature
4+
5+
* Mobile connection via sms (test)
6+
7+
### Fixed
8+
9+
* Adjusts in redis
10+
* Send global event in websocket
11+
* Adjusts in proxy
12+
* Fix audio encoding
13+
* Fix conversation read on chatwoot version 3.7
14+
* Fix when receiving/sending messages from whatsapp desktop with ephemeral messages enabled
15+
* Changed returned sessions on typebot status change
16+
* Reorganization of files and folders
17+
118
# 1.7.1 (2024-04-03 10:19)
219

320
### Fixed

Docker/.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ RABBITMQ_EXCHANGE_NAME=evolution_exchange
5353
RABBITMQ_URI=amqp://guest:guest@rabbitmq:5672
5454

5555
WEBSOCKET_ENABLED=false
56+
WEBSOCKET_GLOBAL_EVENTS=false
5657

5758
WA_BUSINESS_TOKEN_WEBHOOK=evolution
5859
WA_BUSINESS_URL=https://graph.facebook.com

Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
FROM node:20.7.0-alpine AS builder
22

3-
LABEL version="1.7.1" description="Api to control whatsapp features through http requests."
3+
LABEL version="1.7.2" description="Api to control whatsapp features through http requests."
44
LABEL maintainer="Davidson Gomes" git="https://github.com/DavidsonGomes"
55
LABEL contact="contato@agenciadgcode.com"
66

@@ -68,6 +68,7 @@ ENV RABBITMQ_EXCHANGE_NAME=evolution_exchange
6868
ENV RABBITMQ_URI=amqp://guest:guest@rabbitmq:5672
6969

7070
ENV WEBSOCKET_ENABLED=false
71+
ENV WEBSOCKET_GLOBAL_EVENTS=false
7172

7273
ENV WA_BUSINESS_TOKEN_WEBHOOK=evolution
7374
ENV WA_BUSINESS_URL=https://graph.facebook.com

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "evolution-api",
3-
"version": "1.7.1",
3+
"version": "1.7.2",
44
"description": "Rest api for communication with WhatsApp",
55
"main": "./dist/src/main.js",
66
"scripts": {
@@ -46,7 +46,7 @@
4646
"@figuro/chatwoot-sdk": "^1.1.16",
4747
"@hapi/boom": "^10.0.1",
4848
"@sentry/node": "^7.59.2",
49-
"@whiskeysockets/baileys": "6.6.0",
49+
"@whiskeysockets/baileys": "github:AtendAI/Baileys",
5050
"amqplib": "^0.10.3",
5151
"aws-sdk": "^2.1499.0",
5252
"axios": "^1.6.5",
@@ -60,6 +60,7 @@
6060
"exiftool-vendored": "^22.0.0",
6161
"express": "^4.18.2",
6262
"express-async-errors": "^3.1.1",
63+
"fluent-ffmpeg": "^2.1.2",
6364
"form-data": "^4.0.0",
6465
"hbs": "^4.2.0",
6566
"https-proxy-agent": "^7.0.2",
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/whatsapp/controllers/instance.controller.ts renamed to src/api/controllers/instance.controller.ts

Lines changed: 41 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,22 @@ import { Logger } from '../../config/logger.config';
88
import { BadRequestException, InternalServerErrorException } from '../../exceptions';
99
import { RedisCache } from '../../libs/redis.client';
1010
import { InstanceDto, SetPresenceDto } from '../dto/instance.dto';
11+
import { ChatwootService } from '../integrations/chatwoot/services/chatwoot.service';
12+
import { RabbitmqService } from '../integrations/rabbitmq/services/rabbitmq.service';
13+
import { SqsService } from '../integrations/sqs/services/sqs.service';
14+
import { TypebotService } from '../integrations/typebot/services/typebot.service';
15+
import { WebsocketService } from '../integrations/websocket/services/websocket.service';
1116
import { RepositoryBroker } from '../repository/repository.manager';
1217
import { AuthService, OldToken } from '../services/auth.service';
1318
import { CacheService } from '../services/cache.service';
14-
import { ChatwootService } from '../services/chatwoot.service';
1519
import { IntegrationService } from '../services/integration.service';
1620
import { WAMonitoringService } from '../services/monitor.service';
17-
import { RabbitmqService } from '../services/rabbitmq.service';
1821
import { SettingsService } from '../services/settings.service';
19-
import { SqsService } from '../services/sqs.service';
20-
import { TypebotService } from '../services/typebot.service';
2122
import { WebhookService } from '../services/webhook.service';
22-
import { WebsocketService } from '../services/websocket.service';
23-
import { BaileysStartupService } from '../services/whatsapp.baileys.service';
24-
import { BusinessStartupService } from '../services/whatsapp.business.service';
23+
import { BaileysStartupService } from '../services/whatsapp/whatsapp.baileys.service';
24+
import { BusinessStartupService } from '../services/whatsapp/whatsapp.business.service';
2525
import { Events, Integration, wa } from '../types/wa.types';
26+
import { ProxyController } from './proxy.controller';
2627

2728
export class InstanceController {
2829
constructor(
@@ -39,6 +40,7 @@ export class InstanceController {
3940
private readonly sqsService: SqsService,
4041
private readonly typebotService: TypebotService,
4142
private readonly integrationService: IntegrationService,
43+
private readonly proxyService: ProxyController,
4244
private readonly cache: RedisCache,
4345
private readonly chatwootCache: CacheService,
4446
) {}
@@ -53,6 +55,7 @@ export class InstanceController {
5355
events,
5456
qrcode,
5557
number,
58+
mobile,
5659
integration,
5760
token,
5861
chatwoot_account_id,
@@ -84,6 +87,7 @@ export class InstanceController {
8487
typebot_delay_message,
8588
typebot_unknown_message,
8689
typebot_listening_from_me,
90+
proxy,
8791
}: InstanceDto) {
8892
try {
8993
this.logger.verbose('requested createInstance from ' + instanceName + ' instance');
@@ -115,7 +119,7 @@ export class InstanceController {
115119
);
116120
}
117121

118-
await this.waMonitor.saveInstance({ integration, instanceName, token, number });
122+
await this.waMonitor.saveInstance({ integration, instanceName, token, number, mobile });
119123

120124
instance.instanceName = instanceName;
121125

@@ -345,6 +349,18 @@ export class InstanceController {
345349
}
346350
}
347351

352+
if (proxy) {
353+
const testProxy = await this.proxyService.testProxy(proxy);
354+
if (!testProxy) {
355+
throw new BadRequestException('Invalid proxy');
356+
}
357+
358+
await this.proxyService.createProxy(instance, {
359+
enabled: true,
360+
proxy,
361+
});
362+
}
363+
348364
if (typebot_url) {
349365
try {
350366
if (!isURL(typebot_url, { require_tld: false })) {
@@ -405,7 +421,7 @@ export class InstanceController {
405421

406422
if (qrcode) {
407423
this.logger.verbose('creating qrcode');
408-
await instance.connectToWhatsapp(number);
424+
await instance.connectToWhatsapp(number, mobile);
409425
await delay(5000);
410426
getQrcode = instance.qrCode;
411427
}
@@ -569,7 +585,7 @@ export class InstanceController {
569585
}
570586
}
571587

572-
public async connectToWhatsapp({ instanceName, number = null }: InstanceDto) {
588+
public async connectToWhatsapp({ instanceName, number = null, mobile = null }: InstanceDto) {
573589
try {
574590
this.logger.verbose('requested connectToWhatsapp from ' + instanceName + ' instance');
575591

@@ -592,7 +608,7 @@ export class InstanceController {
592608

593609
if (state == 'close') {
594610
this.logger.verbose('connecting');
595-
await instance.connectToWhatsapp(number);
611+
await instance.connectToWhatsapp(number, mobile);
596612

597613
await delay(5000);
598614
return instance.qrCode;
@@ -633,6 +649,20 @@ export class InstanceController {
633649
}
634650
}
635651

652+
public async registerMobileCode({ instanceName }: InstanceDto, { mobileCode }: any) {
653+
try {
654+
this.logger.verbose('requested registerMobileCode from ' + instanceName + ' instance');
655+
656+
const instance = this.waMonitor.waInstances[instanceName];
657+
658+
console.log('mobileCode', mobileCode);
659+
await instance.receiveMobileCode(mobileCode);
660+
return { status: 'SUCCESS', error: false, response: { message: 'Mobile code registered' } };
661+
} catch (error) {
662+
this.logger.error(error);
663+
}
664+
}
665+
636666
public async connectionState({ instanceName }: InstanceDto) {
637667
this.logger.verbose('requested connectionState from ' + instanceName + ' instance');
638668
return {

0 commit comments

Comments
 (0)