Skip to content

Commit 9b59895

Browse files
committed
Merge branch 'release/1.1.4'
2 parents 97abb25 + c7600ff commit 9b59895

31 files changed

+1288
-146
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
/dist
33
/node_modules
44

5+
/Docker/.env
6+
57
# Logs
68
logs/**.json
79
*.log
@@ -12,6 +14,7 @@ yarn-error.log*
1214
lerna-debug.log*
1315

1416
/docker-compose-data
17+
/docker-data
1518

1619
# Package
1720
/yarn.lock

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
# 1.1.4 (2023-07-08 11:01)
2+
3+
### Features
4+
5+
* Route to send status broadcast
6+
* Added verbose logs
7+
* Insert allContacts in payload of endpoint sendStatus
8+
9+
### Fixed
10+
11+
* Adjusted set in webhook to go empty when enabled false
12+
* Adjust in store files
13+
* Fixed the problem when do not save contacts when receive messages
14+
* Changed owner of the jid for instanceName
15+
* Create .env for installation in docker
16+
117
# 1.1.3 (2023-07-06 11:43)
218

319
### Features

Docker/.env.example

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
CORS_ORIGIN='*' # Or separate by commas - ex.: 'yourdomain1.com, yourdomain2.com'
2+
CORS_METHODS='POST,GET,PUT,DELETE'
3+
CORS_CREDENTIALS=true
4+
5+
# Determine the logs to be displayed
6+
LOG_LEVEL='ERROR,WARN,DEBUG,INFO,LOG,VERBOSE,DARK,WEBHOOKS'
7+
LOG_COLOR=true
8+
LOG_BAILEYS=error # "fatal" | "error" | "warn" | "info" | "debug" | "trace"
9+
10+
# Determine how long the instance should be deleted from memory in case of no connection.
11+
# Default time: 5 minutes
12+
# If you don't even want an expiration, enter the value false
13+
DEL_INSTANCE=false
14+
15+
# Temporary data storage
16+
STORE_MESSAGES=true
17+
STORE_MESSAGE_UP=true
18+
STORE_CONTACTS=true
19+
STORE_CHATS=true
20+
CLEAN_STORE_CLEANING_INTERVAL=7200 # seconds === 2h
21+
CLEAN_STORE_MESSAGES=true
22+
CLEAN_STORE_MESSAGE_UP=true
23+
CLEAN_STORE_CONTACTS=true
24+
CLEAN_STORE_CHATS=true
25+
26+
# Permanent data storage
27+
DATABASE_ENABLED=false
28+
DATABASE_CONNECTION_URI=mongodb://root:root@mongodb:27017/?authSource=admin&readPreference=primary&ssl=false&directConnection=true
29+
DATABASE_CONNECTION_DB_PREFIX_NAME=evolution
30+
31+
# Choose the data you want to save in the application's database or store
32+
DATABASE_SAVE_DATA_INSTANCE=true
33+
DATABASE_SAVE_DATA_OLD_MESSAGE=false
34+
DATABASE_SAVE_DATA_NEW_MESSAGE=true
35+
DATABASE_SAVE_MESSAGE_UPDATE=true
36+
DATABASE_SAVE_DATA_CONTACTS=true
37+
DATABASE_SAVE_DATA_CHATS=true
38+
39+
REDIS_ENABLED=false
40+
REDIS_URI=redis://redis:6379/1
41+
REDIS_PREFIX_KEY=evolution
42+
43+
# Webhook Settings
44+
## Define a global webhook that will listen for enabled events from all instances
45+
WEBHOOK_GLOBAL_URL='<url>'
46+
WEBHOOK_GLOBAL_ENABLED=false
47+
# With this option activated, you work with a url per webhook event, respecting the global url and the name of each event
48+
WEBHOOK_GLOBAL_WEBHOOK_BY_EVENTS=false
49+
## Set the events you want to hear
50+
WEBHOOK_EVENTS_APPLICATION_STARTUP=false
51+
WEBHOOK_EVENTS_QRCODE_UPDATED=true
52+
WEBHOOK_EVENTS_MESSAGES_SET=true
53+
WEBHOOK_EVENTS_MESSAGES_UPSERT=true
54+
WEBHOOK_EVENTS_MESSAGES_UPDATE=true
55+
WEBHOOK_EVENTS_CONTACTS_SET=true
56+
WEBHOOK_EVENTS_CONTACTS_UPSERT=true
57+
WEBHOOK_EVENTS_CONTACTS_UPDATE=true
58+
WEBHOOK_EVENTS_PRESENCE_UPDATE=true
59+
WEBHOOK_EVENTS_CHATS_SET=true
60+
WEBHOOK_EVENTS_CHATS_UPSERT=true
61+
WEBHOOK_EVENTS_CHATS_UPDATE=true
62+
WEBHOOK_EVENTS_CHATS_DELETE=true
63+
WEBHOOK_EVENTS_GROUPS_UPSERT=true
64+
WEBHOOK_EVENTS_GROUPS_UPDATE=true
65+
WEBHOOK_EVENTS_GROUP_PARTICIPANTS_UPDATE=true
66+
WEBHOOK_EVENTS_CONNECTION_UPDATE=true
67+
# This event fires every time a new token is requested via the refresh route
68+
WEBHOOK_EVENTS_NEW_JWT_TOKEN=true
69+
70+
# Name that will be displayed on smartphone connection
71+
CONFIG_SESSION_PHONE_CLIENT=Evolution API
72+
CONFIG_SESSION_PHONE_NAME=chrome # chrome | firefox | edge | opera | safari
73+
74+
# Set qrcode display limit
75+
QRCODE_LIMIT=30
76+
77+
# Defines an authentication type for the api
78+
AUTHENTICATION_TYPE='apikey' # jwt or 'apikey'
79+
## Define a global apikey to access all instances.
80+
### OBS: This key must be inserted in the request header to create an instance.
81+
AUTHENTICATION_API_KEY='B6D711FCDE4D4FD5936544120E713976'
82+
AUTHENTICATION_EXPOSE_IN_FETCH_INSTANCES=true
83+
## Set the secret key to encrypt and decrypt your token and its expiration time
84+
AUTHENTICATION_JWT_EXPIRIN_IN=0 # seconds - 3600s ===1h | zero (0) - never expires
85+
AUTHENTICATION_JWT_SECRET='L0YWtjb2w554WFqPG'
86+
# Set the instance name and webhook url to create an instance in init the application
87+
# With this option activated, you work with a url per webhook event, respecting the local url and the name of each event
88+
AUTHENTICATION_INSTANCE_MODE=server # container or server
89+
# if you are using container mode, set the container name and the webhook url to default instance
90+
AUTHENTICATION_INSTANCE_NAME=evolution
91+
AUTHENTICATION_INSTANCE_WEBHOOK_URL=<url>

Docker/redis/docker-compose.yaml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,6 @@ networks:
77
services:
88
redis:
99
image: redis:latest
10-
command: >
11-
redis-server
12-
--port 6379
13-
--appendonly yes
14-
--save 900 1
15-
--save 300 10
16-
--save 60 10000
17-
--appendfsync everysec
18-
volumes:
19-
- evolution_redis:/data
2010
container_name: redis
2111
ports:
2212
- 6379:6379

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ ENV DATABASE_SAVE_DATA_CHATS=$DATABASE_SAVE_DATA_CHATS
4848

4949
ENV REDIS_ENABLED=$REDIS_ENABLED
5050
ENV REDIS_URI=$REDIS_URI
51+
ENV REDIS_PREFIX_KEY=$REDIS_PREFIX_KEY
5152

5253
ENV WEBHOOK_GLOBAL_URL=$WEBHOOK_GLOBAL_URL
5354
ENV WEBHOOK_GLOBAL_ENABLED=$WEBHOOK_GLOBAL_ENABLED

docker-compose.yaml

Lines changed: 3 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -8,89 +8,14 @@ services:
88
api:
99
container_name: evolution_api
1010
image: evolution/api:local
11+
restart: always
1112
ports:
1213
- 8080:8080
1314
volumes:
1415
- evolution_instances:/evolution/instances
1516
- evolution_store:/evolution/store
16-
environment:
17-
- LOG_LEVEL=ERROR,WARN,DEBUG,INFO,LOG,VERBOSE,DARK,WEBHOOKS
18-
- LOG_BAILEYS=error
19-
# Determine how long the instance should be deleted from memory in case of no connection.
20-
# Default time: 5 minutes
21-
# If you don't even want an expiration, enter the value false
22-
- DEL_INSTANCE=false # 5 or false
23-
# Temporary data storage
24-
- STORE_MESSAGES=true
25-
- STORE_MESSAGE_UP=true
26-
- STORE_CONTACTS=true
27-
- STORE_CHATS=true
28-
- CLEAN_STORE_CLEANING_INTERVAL=7200 # seconds === 2h
29-
- CLEAN_STORE_MESSAGES=true
30-
- CLEAN_STORE_MESSAGE_UP=true
31-
- CLEAN_STORE_CONTACTS=true
32-
- CLEAN_STORE_CHATS=true
33-
# Permanent data storage
34-
- DATABASE_ENABLED=false
35-
- DATABASE_CONNECTION_URI=mongodb://root:root@mongodb:27017/?authSource=admin&readPreference=primary&ssl=false&directConnection=true
36-
- DATABASE_CONNECTION_DB_PREFIX_NAME=evolution
37-
# Choose the data you want to save in the application's database or store
38-
- DATABASE_SAVE_DATA_INSTANCE=true
39-
- DATABASE_SAVE_DATA_OLD_MESSAGE=false
40-
- DATABASE_SAVE_DATA_NEW_MESSAGE=true
41-
- DATABASE_SAVE_MESSAGE_UPDATE=true
42-
- DATABASE_SAVE_DATA_CONTACTS=true
43-
- DATABASE_SAVE_DATA_CHATS=true
44-
- REDIS_ENABLED=true
45-
- REDIS_URI=redis://redis:6379/1
46-
- REDIS_PREFIX_KEY=evolution
47-
# Webhook Settings
48-
# Define a global webhook that will listen for enabled events from all instances
49-
- WEBHOOK_GLOBAL_URL=<url>
50-
- WEBHOOK_GLOBAL_ENABLED=false
51-
# With this option activated, you work with a url per webhook event, respecting the global url and the name of each event
52-
- WEBHOOK_GLOBAL_WEBHOOK_BY_EVENTS=false
53-
# Automatically maps webhook paths
54-
# Set the events you want to hear
55-
- WEBHOOK_EVENTS_APPLICATION_STARTUP=false
56-
- WEBHOOK_EVENTS_QRCODE_UPDATED=true
57-
- WEBHOOK_EVENTS_MESSAGES_SET=true
58-
- WEBHOOK_EVENTS_MESSAGES_UPSERT=true
59-
- WEBHOOK_EVENTS_MESSAGES_UPDATE=true
60-
- WEBHOOK_EVENTS_CONTACTS_SET=true
61-
- WEBHOOK_EVENTS_CONTACTS_UPSERT=true
62-
- WEBHOOK_EVENTS_CONTACTS_UPDATE=true
63-
- WEBHOOK_EVENTS_PRESENCE_UPDATE=true
64-
- WEBHOOK_EVENTS_CHATS_SET=true
65-
- WEBHOOK_EVENTS_CHATS_UPSERT=true
66-
- WEBHOOK_EVENTS_CHATS_UPDATE=true
67-
- WEBHOOK_EVENTS_CHATS_DELETE=true
68-
- WEBHOOK_EVENTS_GROUPS_UPSERT=true
69-
- WEBHOOK_EVENTS_GROUPS_UPDATE=true
70-
- WEBHOOK_EVENTS_GROUP_PARTICIPANTS_UPDATE=true
71-
- WEBHOOK_EVENTS_CONNECTION_UPDATE=true
72-
# This event fires every time a new token is requested via the refresh route
73-
- WEBHOOK_EVENTS_NEW_JWT_TOKEN=true
74-
# Name that will be displayed on smartphone connection
75-
- CONFIG_SESSION_PHONE_CLIENT=Evolution API
76-
- CONFIG_SESSION_PHONE_NAME=chrome # chrome | firefox | edge | opera | safari
77-
# Set qrcode display limit
78-
- QRCODE_LIMIT=30
79-
# Defines an authentication type for the api
80-
- AUTHENTICATION_TYPE=apikey # jwt or apikey
81-
# Define a global apikey to access all instances
82-
# OBS: This key must be inserted in the request header to create an instance.
83-
- AUTHENTICATION_API_KEY=B6D711FCDE4D4FD5936544120E713976
84-
# Expose the api key on return from fetch instances
85-
- AUTHENTICATION_EXPOSE_IN_FETCH_INSTANCES=true
86-
# Set the secret key to encrypt and decrypt your token and its expiration time.
87-
- AUTHENTICATION_JWT_EXPIRIN_IN=0 # seconds - 3600s === 1h | zero (0) - never expires
88-
# Set the instance name and webhook url to create an instance in init the application
89-
# With this option activated, you work with a url per webhook event, respecting the local url and the name of each event
90-
- AUTHENTICATION_INSTANCE_MODE=server # container or server
91-
# if you are using container mode, set the container name and the webhook url to default instance
92-
- AUTHENTICATION_INSTANCE_NAME=evolution
93-
- AUTHENTICATION_INSTANCE_WEBHOOK_URL=<url>
17+
env_file:
18+
- ./Docker/.env
9419
command: ['node', './dist/src/main.js']
9520
networks:
9621
- evolution-net

package.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "evolution-api",
3-
"version": "1.1.3",
3+
"version": "1.1.4",
44
"description": "Rest api for communication with WhatsApp",
55
"main": "./dist/src/main.js",
66
"scripts": {
@@ -12,7 +12,7 @@
1212
},
1313
"repository": {
1414
"type": "git",
15-
"url": "git+https://github.com/DavidsonGomes/evolution-api.git"
15+
"url": "git+https://github.com/EvolutionAPI/evolution-api.git"
1616
},
1717
"keywords": [
1818
"chat",
@@ -36,14 +36,14 @@
3636
},
3737
"license": "GPL-3.0",
3838
"bugs": {
39-
"url": "https://github.com/DavidsonGomes/evolution-api/issues"
39+
"url": "https://github.com/EvolutionAPI/evolution-api/issues"
4040
},
41-
"homepage": "https://github.com/DavidsonGomes/evolution-api#readme",
41+
"homepage": "https://github.com/EvolutionAPI/evolution-api#readme",
4242
"dependencies": {
4343
"@adiwajshing/keyed-db": "^0.2.4",
4444
"@ffmpeg-installer/ffmpeg": "^1.1.0",
4545
"@hapi/boom": "^10.0.1",
46-
"@whiskeysockets/baileys": "^6.3.0",
46+
"@whiskeysockets/baileys": "github:EvolutionAPI/Baileys",
4747
"axios": "^1.3.5",
4848
"class-validator": "^0.13.2",
4949
"compression": "^1.7.4",
@@ -65,6 +65,7 @@
6565
"node-cache": "^5.1.2",
6666
"node-mime-types": "^1.1.0",
6767
"pino": "^8.11.0",
68+
"proxy-agent": "^6.2.1",
6869
"qrcode": "^1.5.1",
6970
"qrcode-terminal": "^0.12.0",
7071
"redis": "^4.6.5",

src/config/path.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ export const ROOT_DIR = process.cwd();
44
export const INSTANCE_DIR = join(ROOT_DIR, 'instances');
55
export const SRC_DIR = join(ROOT_DIR, 'src');
66
export const AUTH_DIR = join(ROOT_DIR, 'store', 'auth');
7+
export const STORE_DIR = join(ROOT_DIR, 'store');

src/db/redis.client.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,11 @@ export class RedisCache {
104104
public async delAll(hash?: string) {
105105
try {
106106
this.logger.verbose('instance delAll: ' + hash);
107-
return await this.client.del(
107+
const result = await this.client.del(
108108
hash || this.redisEnv.PREFIX_KEY + ':' + this.instanceName,
109109
);
110+
111+
return result;
110112
} catch (error) {
111113
this.logger.error(error);
112114
}

src/validate/validate.schema.ts

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export const instanceNameSchema: JSONSchema7 = {
3030
webhook_by_events: { type: 'boolean' },
3131
events: {
3232
type: 'array',
33-
minItems: 1,
33+
minItems: 0,
3434
items: {
3535
type: 'string',
3636
enum: [
@@ -189,6 +189,37 @@ export const pollMessageSchema: JSONSchema7 = {
189189
required: ['pollMessage', 'number'],
190190
};
191191

192+
export const statusMessageSchema: JSONSchema7 = {
193+
$id: v4(),
194+
type: 'object',
195+
properties: {
196+
statusMessage: {
197+
type: 'object',
198+
properties: {
199+
type: { type: 'string', enum: ['text', 'image', 'audio', 'video'] },
200+
content: { type: 'string' },
201+
caption: { type: 'string' },
202+
backgroundColor: { type: 'string' },
203+
font: { type: 'integer', minimum: 0, maximum: 5 },
204+
statusJidList: {
205+
type: 'array',
206+
minItems: 1,
207+
uniqueItems: true,
208+
items: {
209+
type: 'string',
210+
pattern: '^\\d+',
211+
description: '"statusJidList" must be an array of numeric strings',
212+
},
213+
},
214+
allContacts: { type: 'boolean', enum: [true, false] },
215+
},
216+
required: ['type', 'content'],
217+
...isNotEmpty('type', 'content'),
218+
},
219+
},
220+
required: ['statusMessage'],
221+
};
222+
192223
export const mediaMessageSchema: JSONSchema7 = {
193224
$id: v4(),
194225
type: 'object',
@@ -795,7 +826,7 @@ export const webhookSchema: JSONSchema7 = {
795826
enabled: { type: 'boolean', enum: [true, false] },
796827
events: {
797828
type: 'array',
798-
minItems: 1,
829+
minItems: 0,
799830
items: {
800831
type: 'string',
801832
enum: [

src/whatsapp/abstract/abstract.repository.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ import { ROOT_DIR } from '../../config/path.config';
66
export type IInsert = { insertCount: number };
77

88
export interface IRepository {
9-
insert(data: any, saveDb?: boolean): Promise<IInsert>;
9+
insert(data: any, instanceName: string, saveDb?: boolean): Promise<IInsert>;
10+
update(data: any, instanceName: string, saveDb?: boolean): Promise<IInsert>;
1011
find(query: any): Promise<any>;
1112
delete(query: any, force?: boolean): Promise<any>;
1213

@@ -45,9 +46,14 @@ export abstract class Repository implements IRepository {
4546
}
4647
};
4748

48-
public insert(data: any, saveDb = false): Promise<IInsert> {
49+
public insert(data: any, instanceName: string, saveDb = false): Promise<IInsert> {
4950
throw new Error('Method not implemented.');
5051
}
52+
53+
public update(data: any, instanceName: string, saveDb = false): Promise<IInsert> {
54+
throw new Error('Method not implemented.');
55+
}
56+
5157
public find(query: any): Promise<any> {
5258
throw new Error('Method not implemented.');
5359
}

0 commit comments

Comments
 (0)