Skip to content

Commit 77775e2

Browse files
committed
Merge branch 'release/1.2.1'
2 parents 43a8b34 + b260959 commit 77775e2

File tree

7 files changed

+175
-32
lines changed

7 files changed

+175
-32
lines changed

CHANGELOG.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
# 1.2.0 (homolog)
1+
# 1.2.1 (homolog)
2+
3+
### Fixed
4+
5+
* Adjusts in docker files
6+
* Save picture url groups in chatwoot
7+
8+
# 1.2.0 (2023-07-14 15:28)
29

310
### Features
411

Docker/mongodb/docker-compose.yaml

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
version: '3.3'
22

3-
networks:
4-
evolution-net:
5-
driver: bridge
6-
73
services:
84
mongodb:
95
container_name: mongodb
@@ -24,6 +20,24 @@ services:
2420
expose:
2521
- 27017
2622

23+
mongo-express:
24+
image: mongo-express
25+
environment:
26+
ME_CONFIG_BASICAUTH_USERNAME: root
27+
ME_CONFIG_BASICAUTH_PASSWORD: root
28+
ME_CONFIG_MONGODB_SERVER: mongodb
29+
ME_CONFIG_MONGODB_ADMINUSERNAME: root
30+
ME_CONFIG_MONGODB_ADMINPASSWORD: root
31+
ports:
32+
- 8081:8081
33+
links:
34+
- mongodb
35+
2736
volumes:
2837
evolution_mongodb_data:
29-
evolution_mongodb_configdb:
38+
evolution_mongodb_configdb:
39+
40+
networks:
41+
default:
42+
name: evolution-net
43+

Docker/redis/docker-compose.yaml

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
version: '3.3'
22

3-
networks:
4-
evolution-net:
5-
driver: bridge
6-
73
services:
84
redis:
95
image: redis:latest
@@ -16,8 +12,17 @@ services:
1612
- evolution_redis:/data
1713
ports:
1814
- 6379:6379
19-
networks:
20-
- evolution-net
21-
15+
16+
rebrow:
17+
image: marian/rebrow
18+
ports:
19+
- 5001:5001
20+
links:
21+
- redis
22+
2223
volumes:
2324
evolution_redis:
25+
26+
networks:
27+
default:
28+
name: evolution-net

docker-compose-full.yaml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
version: '3.3'
2+
3+
services:
4+
redis:
5+
image: redis:latest
6+
container_name: redis
7+
ports:
8+
- 6379:6379
9+
10+
rebrow:
11+
image: marian/rebrow
12+
ports:
13+
- 5001:5001
14+
links:
15+
- redis
16+
17+
mongodb:
18+
container_name: mongodb
19+
image: mongo
20+
restart: always
21+
volumes:
22+
- evolution_mongodb_data:/data/db
23+
- evolution_mongodb_configdb:/data/configdb
24+
ports:
25+
- 27017:27017
26+
environment:
27+
MONGO_INITDB_ROOT_USERNAME: root
28+
MONGO_INITDB_ROOT_PASSWORD: root
29+
expose:
30+
- 27017
31+
32+
mongo-express:
33+
image: mongo-express
34+
environment:
35+
ME_CONFIG_BASICAUTH_USERNAME: root
36+
ME_CONFIG_BASICAUTH_PASSWORD: root
37+
ME_CONFIG_MONGODB_SERVER: mongodb
38+
ME_CONFIG_MONGODB_ADMINUSERNAME: root
39+
ME_CONFIG_MONGODB_ADMINPASSWORD: root
40+
ports:
41+
- 8081:8081
42+
links:
43+
- mongodb
44+
api:
45+
container_name: evolution_api
46+
image: evolution/api:local
47+
restart: always
48+
ports:
49+
- 8080:8080
50+
volumes:
51+
- evolution_instances:/evolution/instances
52+
- evolution_store:/evolution/store
53+
env_file:
54+
- ./Docker/.env
55+
command: ['node', './dist/src/main.js']
56+
expose:
57+
- 8080
58+
links:
59+
- mongodb
60+
- redis
61+
62+
volumes:
63+
evolution_instances:
64+
evolution_store:
65+
evolution_mongodb_data:
66+
evolution_mongodb_configdb:
67+
evolution_redis:
68+
69+
networks:
70+
default:
71+
name: evolution-net
72+

docker-compose.yaml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
version: '3.3'
22

3-
networks:
4-
evolution-net:
5-
driver: bridge
6-
73
services:
84
api:
95
container_name: evolution_api
@@ -17,11 +13,14 @@ services:
1713
env_file:
1814
- ./Docker/.env
1915
command: ['node', './dist/src/main.js']
20-
networks:
21-
- evolution-net
2216
expose:
2317
- 8080
2418

2519
volumes:
2620
evolution_instances:
27-
evolution_store:
21+
evolution_store:
22+
23+
networks:
24+
default:
25+
name: evolution-net
26+

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.2.0",
3+
"version": "1.2.1",
44
"description": "Rest api for communication with WhatsApp",
55
"main": "./dist/src/main.js",
66
"scripts": {

src/whatsapp/services/chatwoot.service.ts

Lines changed: 57 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ export class ChatwootService {
4343
this.logger.verbose('message cache saved');
4444
}
4545

46+
private clearMessageCache() {
47+
this.logger.verbose('clear message cache');
48+
this.messageCache.clear();
49+
this.saveMessageCache();
50+
}
51+
4652
private async getProvider(instance: InstanceDto) {
4753
this.logger.verbose('get provider to instance: ' + instance.instanceName);
4854
try {
@@ -258,6 +264,7 @@ export class ChatwootService {
258264
inboxId: number,
259265
isGroup: boolean,
260266
name?: string,
267+
avatar_url?: string,
261268
) {
262269
this.logger.verbose('create contact to instance: ' + instance.instanceName);
263270

@@ -275,13 +282,15 @@ export class ChatwootService {
275282
inbox_id: inboxId,
276283
name: name || phoneNumber,
277284
phone_number: `+${phoneNumber}`,
285+
avatar_url: avatar_url,
278286
};
279287
} else {
280288
this.logger.verbose('create contact group in chatwoot');
281289
data = {
282290
inbox_id: inboxId,
283291
name: name || phoneNumber,
284292
identifier: phoneNumber,
293+
avatar_url: avatar_url,
285294
};
286295
}
287296

@@ -404,34 +413,67 @@ export class ChatwootService {
404413
nameContact = `${group.subject} (GROUP)`;
405414

406415
this.logger.verbose('find or create participant in chatwoot');
407-
const participant =
408-
(await this.findContact(instance, body.key.participant.split('@')[0])) ||
409-
((await this.createContact(
416+
417+
const picture_url = await this.waMonitor.waInstances[
418+
instance.instanceName
419+
].profilePicture(body.key.participant.split('@')[0]);
420+
421+
const findParticipant = await this.findContact(
422+
instance,
423+
body.key.participant.split('@')[0],
424+
);
425+
426+
if (findParticipant) {
427+
await this.updateContact(instance, findParticipant.id, {
428+
name: nameContact,
429+
avatar_url: picture_url.profilePictureUrl || null,
430+
});
431+
} else {
432+
await this.createContact(
410433
instance,
411434
body.key.participant.split('@')[0],
412435
filterInbox.id,
413-
false,
414-
body.pushName || body.key.participant.split('@')[0],
415-
)) as any);
436+
isGroup,
437+
nameContact,
438+
picture_url.profilePictureUrl || null,
439+
);
440+
}
416441
}
417442

418443
this.logger.verbose('find or create contact in chatwoot');
419-
const contact =
420-
(await this.findContact(instance, chatId)) ||
421-
((await this.createContact(
444+
445+
const picture_url = await this.waMonitor.waInstances[
446+
instance.instanceName
447+
].profilePicture(chatId);
448+
449+
const findContact = await this.findContact(instance, chatId);
450+
451+
let contact: any;
452+
453+
if (findContact) {
454+
contact = await this.updateContact(instance, findContact.id, {
455+
name: nameContact,
456+
avatar_url: picture_url.profilePictureUrl || null,
457+
});
458+
} else {
459+
contact = await this.createContact(
422460
instance,
423461
chatId,
424462
filterInbox.id,
425463
isGroup,
426464
nameContact,
427-
)) as any);
465+
picture_url.profilePictureUrl || null,
466+
);
467+
}
428468

429469
if (!contact) {
430470
this.logger.warn('contact not found');
431471
return null;
432472
}
433473

434-
const contactId = contact.id || contact.payload.contact.id;
474+
console.log(contact);
475+
476+
const contactId = contact.payload.id || contact.payload.contact.id;
435477

436478
if (!body.key.fromMe && contact.name === chatId && nameContact !== chatId) {
437479
this.logger.verbose('update contact name in chatwoot');
@@ -968,6 +1010,9 @@ export class ChatwootService {
9681010
return { message: 'bot' };
9691011
}
9701012

1013+
this.logger.verbose('clear cache');
1014+
this.clearMessageCache();
1015+
9711016
this.logger.verbose('Format message to send');
9721017
let formatText: string;
9731018
if (senderName === null || senderName === undefined) {
@@ -1124,6 +1169,7 @@ export class ChatwootService {
11241169
}
11251170

11261171
if (event === 'messages.upsert') {
1172+
console.log(body);
11271173
this.logger.verbose('event messages.upsert');
11281174

11291175
if (body.key.remoteJid === 'status@broadcast') {

0 commit comments

Comments
 (0)