Skip to content

Commit 3545b80

Browse files
committed
Merge branch 'release/1.6.0'
2 parents 8fe75cd + 3798557 commit 3545b80

Some content is hidden

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

47 files changed

+1862
-560
lines changed

.DS_Store

2 KB
Binary file not shown.

.vscode/settings.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
"editor.smoothScrolling": true,
66
"editor.tabSize": 2,
77
"editor.codeActionsOnSave": {
8-
"source.fixAll.eslint": true,
9-
"source.fixAll": true
10-
}
8+
"source.fixAll.eslint": "explicit",
9+
"source.fixAll": "explicit"
10+
},
11+
"prisma-smart-formatter.typescript.defaultFormatter": "esbenp.prettier-vscode",
12+
"prisma-smart-formatter.prisma.defaultFormatter": "Prisma.prisma"
1113
}

CHANGELOG.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,44 @@
1+
# 1.6.1 (develop)
2+
3+
### Fixed
4+
5+
* Fixed Lid Messages
6+
7+
# 1.6.0 (2023-12-12 17:24)
8+
9+
### Feature
10+
* Added AWS SQS Integration
11+
* Added support for new typebot API
12+
* Added endpoint sendPresence
13+
* New Instance Manager
14+
* Added auto_create to the chatwoot set to create the inbox automatically or not
15+
* Added reply, delete and message reaction in chatwoot v3.3.1
16+
17+
### Fixed
18+
19+
* Adjusts in proxy
20+
* Adjusts in start session for Typebot
21+
* Added mimetype field when sending media
22+
* Ajusts in validations to messages.upsert
23+
* Fixed messages not received: error handling when updating contact in chatwoot
24+
* Fix workaround to manage param data as an array in mongodb
25+
* Removed await from webhook when sending a message
26+
* Update typebot.service.ts - element.underline change ~ for *
27+
* Adjusts in proxy
28+
* Removed api restart on receiving an error
29+
* Fixes in mongodb and chatwoot
30+
* Adjusted return from queries in mongodb
31+
* Added restart instance when update profile picture
32+
* Correction of chatwoot functioning with admin flows
33+
* Fixed problem that did not generate qrcode with the chatwoot_conversation_pending option enabled
34+
* Fixed issue where CSAT opened a new ticket when reopen_conversation was disabled
35+
* Fixed issue sending contact to Chatwoot via iOS
36+
37+
### Integrations
38+
39+
- Chatwoot: v3.3.1
40+
- Typebot: v2.20.0
41+
142
# 1.5.4 (2023-10-09 20:43)
243

344
### Fixed

Docker/.env.example

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ RABBITMQ_URI=amqp://guest:guest@rabbitmq:5672
5151

5252
WEBSOCKET_ENABLED=false
5353

54+
SQS_ENABLED=false
55+
SQS_ACCESS_KEY_ID=
56+
SQS_SECRET_ACCESS_KEY=
57+
SQS_ACCOUNT_ID=
58+
SQS_REGION=
59+
5460
# Global Webhook Settings
5561
# Each instance's Webhook URL and events will be requested at the time it is created
5662
## Define a global webhook that will listen for enabled events from all instances
@@ -99,6 +105,9 @@ CONFIG_SESSION_PHONE_NAME=Chrome
99105
QRCODE_LIMIT=30
100106
QRCODE_COLOR=#198754
101107

108+
# old | latest
109+
TYPEBOT_API_VERSION=latest
110+
102111
# Defines an authentication type for the api
103112
# We recommend using the apikey because it will allow you to use a custom token,
104113
# if you use jwt, a random token will be generated and may be expired and you will have to generate a new token

Dockerfile

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

3-
LABEL version="1.5.4" description="Api to control whatsapp features through http requests."
3+
LABEL version="1.6.0" description="Api to control whatsapp features through http requests."
44
LABEL maintainer="Davidson Gomes" git="https://github.com/DavidsonGomes"
55
LABEL contact="[email protected]"
66

@@ -56,6 +56,12 @@ ENV RABBITMQ_URI=amqp://guest:guest@rabbitmq:5672
5656

5757
ENV WEBSOCKET_ENABLED=false
5858

59+
ENV SQS_ENABLED=false
60+
ENV SQS_ACCESS_KEY_ID=
61+
ENV SQS_SECRET_ACCESS_KEY=
62+
ENV SQS_ACCOUNT_ID=
63+
ENV SQS_REGION=
64+
5965
ENV WEBHOOK_GLOBAL_URL=
6066
ENV WEBHOOK_GLOBAL_ENABLED=false
6167

@@ -98,6 +104,8 @@ ENV CONFIG_SESSION_PHONE_NAME=Chrome
98104
ENV QRCODE_LIMIT=30
99105
ENV QRCODE_COLOR=#198754
100106

107+
ENV TYPEBOT_API_VERSION=latest
108+
101109
ENV AUTHENTICATION_TYPE=apikey
102110

103111
ENV AUTHENTICATION_API_KEY=B6D711FCDE4D4FD5936544120E713976

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,13 @@ This code was produced based on the baileys library and it is still under develo
3939
</a>
4040
</div>
4141

42-
#### Buy me coffe
42+
#### Buy me coffe - PIX
4343

4444
<div align="center">
4545
<a href="https://bmc.link/evolutionapi" target="_blank" rel="noopener noreferrer">
46-
<img src="./public/images/bmc_qr.png" style="width: 50% !important;">
46+
<img src="./public/images/qrcode-pix.png" style="width: 50% !important;">
4747
</a>
48+
<p><b>CHAVE PIX (Telefone):</b> (74)99987-9409</p>
4849
</div>
4950

5051
</br>

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "evolution-api",
3-
"version": "1.5.4",
3+
"version": "1.6.0",
44
"description": "Rest api for communication with WhatsApp",
55
"main": "./dist/src/main.js",
66
"scripts": {
@@ -48,13 +48,15 @@
4848
"@sentry/node": "^7.59.2",
4949
"@whiskeysockets/baileys": "^6.5.0",
5050
"amqplib": "^0.10.3",
51+
"aws-sdk": "^2.1499.0",
5152
"axios": "^1.3.5",
5253
"class-validator": "^0.13.2",
5354
"compression": "^1.7.4",
5455
"cors": "^2.8.5",
5556
"cross-env": "^7.0.3",
5657
"dayjs": "^1.11.7",
5758
"eventemitter2": "^6.4.9",
59+
"evolution-manager": "^0.4.4",
5860
"exiftool-vendored": "^22.0.0",
5961
"express": "^4.18.2",
6062
"express-async-errors": "^3.1.1",

public/images/qrcode-pix.png

3.57 KB
Loading

src/config/env.config.ts

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,16 @@ export type Rabbitmq = {
6666
URI: string;
6767
};
6868

69-
export type Websocket = {
69+
export type Sqs = {
7070
ENABLED: boolean;
71+
ACCESS_KEY_ID: string;
72+
SECRET_ACCESS_KEY: string;
73+
ACCOUNT_ID: string;
74+
REGION: string;
7175
};
7276

73-
export type Chatwoot = {
74-
USE_REPLY_ID: boolean;
77+
export type Websocket = {
78+
ENABLED: boolean;
7579
};
7680

7781
export type EventsWebhook = {
@@ -124,6 +128,7 @@ export type SslConf = { PRIVKEY: string; FULLCHAIN: string };
124128
export type Webhook = { GLOBAL?: GlobalWebhook; EVENTS: EventsWebhook };
125129
export type ConfigSessionPhone = { CLIENT: string; NAME: string };
126130
export type QrCode = { LIMIT: number; COLOR: string };
131+
export type Typebot = { API_VERSION: string };
127132
export type Production = boolean;
128133

129134
export interface Env {
@@ -135,15 +140,16 @@ export interface Env {
135140
DATABASE: Database;
136141
REDIS: Redis;
137142
RABBITMQ: Rabbitmq;
143+
SQS: Sqs;
138144
WEBSOCKET: Websocket;
139145
LOG: Log;
140146
DEL_INSTANCE: DelInstance;
141147
WEBHOOK: Webhook;
142148
CONFIG_SESSION_PHONE: ConfigSessionPhone;
143149
QRCODE: QrCode;
150+
TYPEBOT: Typebot;
144151
AUTHENTICATION: Auth;
145152
PRODUCTION?: Production;
146-
CHATWOOT?: Chatwoot;
147153
}
148154

149155
export type Key = keyof Env;
@@ -226,6 +232,13 @@ export class ConfigService {
226232
ENABLED: process.env?.RABBITMQ_ENABLED === 'true',
227233
URI: process.env.RABBITMQ_URI || '',
228234
},
235+
SQS: {
236+
ENABLED: process.env?.SQS_ENABLED === 'true',
237+
ACCESS_KEY_ID: process.env.SQS_ACCESS_KEY_ID || '',
238+
SECRET_ACCESS_KEY: process.env.SQS_SECRET_ACCESS_KEY || '',
239+
ACCOUNT_ID: process.env.SQS_ACCOUNT_ID || '',
240+
REGION: process.env.SQS_REGION || '',
241+
},
229242
WEBSOCKET: {
230243
ENABLED: process.env?.WEBSOCKET_ENABLED === 'true',
231244
},
@@ -289,6 +302,9 @@ export class ConfigService {
289302
LIMIT: Number.parseInt(process.env.QRCODE_LIMIT) || 30,
290303
COLOR: process.env.QRCODE_COLOR || '#198754',
291304
},
305+
TYPEBOT: {
306+
API_VERSION: process.env?.TYPEBOT_API_VERSION || 'old',
307+
},
292308
AUTHENTICATION: {
293309
TYPE: process.env.AUTHENTICATION_TYPE as 'apikey',
294310
API_KEY: {
@@ -302,9 +318,6 @@ export class ConfigService {
302318
SECRET: process.env.AUTHENTICATION_JWT_SECRET || 'L=0YWt]b2w[WF>#>:&E`',
303319
},
304320
},
305-
CHATWOOT: {
306-
USE_REPLY_ID: process.env?.USE_REPLY_ID === 'true',
307-
},
308321
};
309322
}
310323
}

src/config/error.config.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ export function onUnexpectedError() {
88
stderr: process.stderr.fd,
99
error,
1010
});
11-
process.exit(1);
1211
});
1312

1413
process.on('unhandledRejection', (error, origin) => {
@@ -18,6 +17,5 @@ export function onUnexpectedError() {
1817
stderr: process.stderr.fd,
1918
error,
2019
});
21-
process.exit(1);
2220
});
2321
}

src/dev-env.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,13 @@ RABBITMQ:
8383
ENABLED: false
8484
URI: "amqp://guest:guest@localhost:5672"
8585

86+
SQS:
87+
ENABLED: true
88+
ACCESS_KEY_ID: ""
89+
SECRET_ACCESS_KEY: ""
90+
ACCOUNT_ID: ""
91+
REGION: "us-east-1"
92+
8693
WEBSOCKET:
8794
ENABLED: false
8895

@@ -139,6 +146,9 @@ QRCODE:
139146
LIMIT: 30
140147
COLOR: "#198754"
141148

149+
TYPEBOT:
150+
API_VERSION: 'old' # old | latest
151+
142152
# Defines an authentication type for the api
143153
# We recommend using the apikey because it will allow you to use a custom token,
144154
# if you use jwt, a random token will be generated and may be expired and you will have to generate a new token
@@ -154,7 +164,3 @@ AUTHENTICATION:
154164
JWT:
155165
EXPIRIN_IN: 0 # seconds - 3600s === 1h | zero (0) - never expires
156166
SECRET: L=0YWt]b2w[WF>#>:&E`
157-
158-
# Configure to chatwoot
159-
CHATWOOT:
160-
USE_REPLY_ID: false

src/docs/swagger.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ info:
2525
</font>
2626
2727
[![Run in Postman](https://run.pstmn.io/button.svg)](https://god.gw.postman.com/run-collection/26869335-5546d063-156b-4529-915f-909dd628c090?action=collection%2Ffork&source=rip_markdown&collection-url=entityId%3D26869335-5546d063-156b-4529-915f-909dd628c090%26entityType%3Dcollection%26workspaceId%3D339a4ee7-378b-45c9-b5b8-fd2c0a9c2442)
28-
version: 1.5.4
28+
version: 1.5.5
2929
contact:
3030
name: DavidsonGomes
3131

src/libs/redis.client.ts

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,49 +5,55 @@ import { Redis } from '../config/env.config';
55
import { Logger } from '../config/logger.config';
66

77
export class RedisCache {
8-
async disconnect() {
9-
await this.client.disconnect();
10-
this.statusConnection = false;
11-
}
12-
constructor() {
13-
this.logger.verbose('instance created');
14-
process.on('beforeExit', async () => {
15-
this.logger.verbose('instance destroyed');
16-
if (this.statusConnection) {
17-
this.logger.verbose('instance disconnect');
18-
await this.client.disconnect();
19-
}
20-
});
21-
}
22-
8+
private readonly logger = new Logger(RedisCache.name);
9+
private client: RedisClientType;
2310
private statusConnection = false;
2411
private instanceName: string;
2512
private redisEnv: Redis;
2613

14+
constructor() {
15+
this.logger.verbose('RedisCache instance created');
16+
process.on('beforeExit', () => {
17+
this.logger.verbose('RedisCache instance destroyed');
18+
this.disconnect();
19+
});
20+
}
21+
2722
public set reference(reference: string) {
2823
this.logger.verbose('set reference: ' + reference);
2924
this.instanceName = reference;
3025
}
3126

3227
public async connect(redisEnv: Redis) {
33-
this.logger.verbose('connecting');
28+
this.logger.verbose('Connecting to Redis...');
3429
this.client = createClient({ url: redisEnv.URI });
35-
this.logger.verbose('connected in ' + redisEnv.URI);
30+
this.client.on('error', (err) => this.logger.error('Redis Client Error ' + err));
31+
3632
await this.client.connect();
3733
this.statusConnection = true;
3834
this.redisEnv = redisEnv;
35+
this.logger.verbose(`Connected to ${redisEnv.URI}`);
3936
}
4037

41-
private readonly logger = new Logger(RedisCache.name);
42-
private client: RedisClientType;
38+
public async disconnect() {
39+
if (this.statusConnection) {
40+
await this.client.disconnect();
41+
this.statusConnection = false;
42+
this.logger.verbose('Redis client disconnected');
43+
}
44+
}
4345

4446
public async instanceKeys(): Promise<string[]> {
47+
const keys: string[] = [];
4548
try {
46-
this.logger.verbose('instance keys: ' + this.redisEnv.PREFIX_KEY + ':*');
47-
return await this.client.sendCommand(['keys', this.redisEnv.PREFIX_KEY + ':*']);
49+
this.logger.verbose('Fetching instance keys');
50+
for await (const key of this.client.scanIterator({ MATCH: `${this.redisEnv.PREFIX_KEY}:*` })) {
51+
keys.push(key);
52+
}
4853
} catch (error) {
49-
this.logger.error(error);
54+
this.logger.error('Error fetching instance keys ' + error);
5055
}
56+
return keys;
5157
}
5258

5359
public async keyExists(key?: string) {

0 commit comments

Comments
 (0)