Skip to content

Commit 82b1567

Browse files
committed
Merge branch 'release/1.4.3'
2 parents f95f312 + 1cd7291 commit 82b1567

File tree

15 files changed

+115
-12
lines changed

15 files changed

+115
-12
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
# 1.4.3 (2023-07-25 10:51)
2+
3+
### Fixed
4+
5+
* Adjusts in settings with options always_online, read_messages and read_status
6+
* Fixed send webhook for event CALL
7+
* Create instance with settings
8+
19
# 1.4.2 (2023-07-24 20:52)
210

311
### Fixed

Docker/.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ WEBHOOK_EVENTS_GROUPS_UPSERT=true
7373
WEBHOOK_EVENTS_GROUPS_UPDATE=true
7474
WEBHOOK_EVENTS_GROUP_PARTICIPANTS_UPDATE=true
7575
WEBHOOK_EVENTS_CONNECTION_UPDATE=true
76+
WEBHOOK_EVENTS_CALL=true
7677
# This event fires every time a new token is requested via the refresh route
7778
WEBHOOK_EVENTS_NEW_JWT_TOKEN=false
7879

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ ENV WEBHOOK_EVENTS_GROUPS_UPSERT=true
7474
ENV WEBHOOK_EVENTS_GROUPS_UPDATE=true
7575
ENV WEBHOOK_EVENTS_GROUP_PARTICIPANTS_UPDATE=true
7676
ENV WEBHOOK_EVENTS_CONNECTION_UPDATE=true
77+
ENV WEBHOOK_EVENTS_CALL=true
7778

7879
ENV WEBHOOK_EVENTS_NEW_JWT_TOKEN=false
7980

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "evolution-api",
3-
"version": "1.4.2",
3+
"version": "1.4.3",
44
"description": "Rest api for communication with WhatsApp",
55
"main": "./dist/src/main.js",
66
"scripts": {

src/config/env.config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ export type EventsWebhook = {
8989
GROUPS_UPSERT: boolean;
9090
GROUP_UPDATE: boolean;
9191
GROUP_PARTICIPANTS_UPDATE: boolean;
92+
CALL: boolean;
9293
NEW_JWT_TOKEN: boolean;
9394
};
9495

@@ -245,6 +246,7 @@ export class ConfigService {
245246
GROUP_UPDATE: process.env?.WEBHOOK_EVENTS_GROUPS_UPDATE === 'true',
246247
GROUP_PARTICIPANTS_UPDATE:
247248
process.env?.WEBHOOK_EVENTS_GROUP_PARTICIPANTS_UPDATE === 'true',
249+
CALL: process.env?.WEBHOOK_EVENTS_CALL === 'true',
248250
NEW_JWT_TOKEN: process.env?.WEBHOOK_EVENTS_NEW_JWT_TOKEN === 'true',
249251
},
250252
},

src/dev-env.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ WEBHOOK:
110110
GROUP_UPDATE: true
111111
GROUP_PARTICIPANTS_UPDATE: true
112112
CONNECTION_UPDATE: true
113+
CALL: true
113114
# This event fires every time a new token is requested via the refresh route
114115
NEW_JWT_TOKEN: false
115116

src/validate/validate.schema.ts

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ export const instanceNameSchema: JSONSchema7 = {
5353
'GROUP_UPDATE',
5454
'GROUP_PARTICIPANTS_UPDATE',
5555
'CONNECTION_UPDATE',
56+
'CALL',
5657
'NEW_JWT_TOKEN',
5758
],
5859
},
@@ -455,7 +456,7 @@ export const readMessageSchema: JSONSchema7 = {
455456
$id: v4(),
456457
type: 'object',
457458
properties: {
458-
readMessages: {
459+
read_messages: {
459460
type: 'array',
460461
minItems: 1,
461462
uniqueItems: true,
@@ -470,7 +471,7 @@ export const readMessageSchema: JSONSchema7 = {
470471
},
471472
},
472473
},
473-
required: ['readMessages'],
474+
required: ['read_messages'],
474475
};
475476

476477
export const privacySettingsSchema: JSONSchema7 = {
@@ -854,6 +855,7 @@ export const webhookSchema: JSONSchema7 = {
854855
'GROUP_UPDATE',
855856
'GROUP_PARTICIPANTS_UPDATE',
856857
'CONNECTION_UPDATE',
858+
'CALL',
857859
'NEW_JWT_TOKEN',
858860
],
859861
},
@@ -884,7 +886,22 @@ export const settingsSchema: JSONSchema7 = {
884886
reject_call: { type: 'boolean', enum: [true, false] },
885887
msg_call: { type: 'string' },
886888
groups_ignore: { type: 'boolean', enum: [true, false] },
887-
},
888-
required: ['reject_call'],
889-
...isNotEmpty('reject_call'),
889+
always_online: { type: 'boolean', enum: [true, false] },
890+
read_messages: { type: 'boolean', enum: [true, false] },
891+
read_status: { type: 'boolean', enum: [true, false] },
892+
},
893+
required: [
894+
'reject_call',
895+
'groups_ignore',
896+
'always_online',
897+
'read_messages',
898+
'read_status',
899+
],
900+
...isNotEmpty(
901+
'reject_call',
902+
'groups_ignore',
903+
'always_online',
904+
'read_messages',
905+
'read_status',
906+
),
890907
};

src/whatsapp/controllers/instance.controller.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { Logger } from '../../config/logger.config';
1313
import { wa } from '../types/wa.types';
1414
import { RedisCache } from '../../db/redis.client';
1515
import { isURL } from 'class-validator';
16+
import { SettingsService } from '../services/settings.service';
1617

1718
export class InstanceController {
1819
constructor(
@@ -23,6 +24,7 @@ export class InstanceController {
2324
private readonly authService: AuthService,
2425
private readonly webhookService: WebhookService,
2526
private readonly chatwootService: ChatwootService,
27+
private readonly settingsService: SettingsService,
2628
private readonly cache: RedisCache,
2729
) {}
2830

@@ -40,6 +42,12 @@ export class InstanceController {
4042
chatwoot_token,
4143
chatwoot_url,
4244
chatwoot_sign_msg,
45+
reject_call,
46+
msg_call,
47+
groups_ignore,
48+
always_online,
49+
read_messages,
50+
read_status,
4351
}: InstanceDto) {
4452
try {
4553
this.logger.verbose('requested createInstance from ' + instanceName + ' instance');
@@ -102,6 +110,20 @@ export class InstanceController {
102110
}
103111
}
104112

113+
this.logger.verbose('creating settings');
114+
const settings: wa.LocalSettings = {
115+
reject_call: reject_call || false,
116+
msg_call: msg_call || '',
117+
groups_ignore: groups_ignore || false,
118+
always_online: always_online || false,
119+
read_messages: read_messages || false,
120+
read_status: read_status || false,
121+
};
122+
123+
this.logger.verbose('settings: ' + JSON.stringify(settings));
124+
125+
this.settingsService.create(instance, settings);
126+
105127
if (!chatwoot_account_id || !chatwoot_token || !chatwoot_url) {
106128
let getQrcode: wa.QrCode;
107129

@@ -121,6 +143,7 @@ export class InstanceController {
121143
webhook,
122144
webhook_by_events,
123145
events: getEvents,
146+
settings,
124147
qrcode: getQrcode,
125148
};
126149

@@ -179,6 +202,7 @@ export class InstanceController {
179202
webhook,
180203
webhook_by_events,
181204
events: getEvents,
205+
settings,
182206
chatwoot: {
183207
enabled: true,
184208
account_id: chatwoot_account_id,

src/whatsapp/dto/chat.dto.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class Key {
5959
remoteJid: string;
6060
}
6161
export class ReadMessageDto {
62-
readMessages: Key[];
62+
read_messages: Key[];
6363
}
6464

6565
class LastMessage {

src/whatsapp/dto/instance.dto.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
export class InstanceDto {
22
instanceName: string;
3-
webhook?: string;
4-
webhook_by_events?: boolean;
5-
events?: string[];
63
qrcode?: boolean;
74
number?: string;
85
token?: string;
6+
webhook?: string;
7+
webhook_by_events?: boolean;
8+
events?: string[];
9+
reject_call?: boolean;
10+
msg_call?: string;
11+
groups_ignore?: boolean;
12+
always_online?: boolean;
13+
read_messages?: boolean;
14+
read_status?: boolean;
915
chatwoot_account_id?: string;
1016
chatwoot_token?: string;
1117
chatwoot_url?: string;

0 commit comments

Comments
 (0)