Merge branch 'release/1.2.1'

This commit is contained in:
Davidson Gomes 2023-07-14 18:04:32 -03:00
commit 77775e2f85
7 changed files with 175 additions and 32 deletions

View File

@ -1,4 +1,11 @@
# 1.2.0 (homolog)
# 1.2.1 (homolog)
### Fixed
* Adjusts in docker files
* Save picture url groups in chatwoot
# 1.2.0 (2023-07-14 15:28)
### Features

View File

@ -1,9 +1,5 @@
version: '3.3'
networks:
evolution-net:
driver: bridge
services:
mongodb:
container_name: mongodb
@ -24,6 +20,24 @@ services:
expose:
- 27017
mongo-express:
image: mongo-express
environment:
ME_CONFIG_BASICAUTH_USERNAME: root
ME_CONFIG_BASICAUTH_PASSWORD: root
ME_CONFIG_MONGODB_SERVER: mongodb
ME_CONFIG_MONGODB_ADMINUSERNAME: root
ME_CONFIG_MONGODB_ADMINPASSWORD: root
ports:
- 8081:8081
links:
- mongodb
volumes:
evolution_mongodb_data:
evolution_mongodb_configdb:
evolution_mongodb_configdb:
networks:
default:
name: evolution-net

View File

@ -1,9 +1,5 @@
version: '3.3'
networks:
evolution-net:
driver: bridge
services:
redis:
image: redis:latest
@ -16,8 +12,17 @@ services:
- evolution_redis:/data
ports:
- 6379:6379
networks:
- evolution-net
rebrow:
image: marian/rebrow
ports:
- 5001:5001
links:
- redis
volumes:
evolution_redis:
networks:
default:
name: evolution-net

72
docker-compose-full.yaml Normal file
View File

@ -0,0 +1,72 @@
version: '3.3'
services:
redis:
image: redis:latest
container_name: redis
ports:
- 6379:6379
rebrow:
image: marian/rebrow
ports:
- 5001:5001
links:
- redis
mongodb:
container_name: mongodb
image: mongo
restart: always
volumes:
- evolution_mongodb_data:/data/db
- evolution_mongodb_configdb:/data/configdb
ports:
- 27017:27017
environment:
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: root
expose:
- 27017
mongo-express:
image: mongo-express
environment:
ME_CONFIG_BASICAUTH_USERNAME: root
ME_CONFIG_BASICAUTH_PASSWORD: root
ME_CONFIG_MONGODB_SERVER: mongodb
ME_CONFIG_MONGODB_ADMINUSERNAME: root
ME_CONFIG_MONGODB_ADMINPASSWORD: root
ports:
- 8081:8081
links:
- mongodb
api:
container_name: evolution_api
image: evolution/api:local
restart: always
ports:
- 8080:8080
volumes:
- evolution_instances:/evolution/instances
- evolution_store:/evolution/store
env_file:
- ./Docker/.env
command: ['node', './dist/src/main.js']
expose:
- 8080
links:
- mongodb
- redis
volumes:
evolution_instances:
evolution_store:
evolution_mongodb_data:
evolution_mongodb_configdb:
evolution_redis:
networks:
default:
name: evolution-net

View File

@ -1,9 +1,5 @@
version: '3.3'
networks:
evolution-net:
driver: bridge
services:
api:
container_name: evolution_api
@ -17,11 +13,14 @@ services:
env_file:
- ./Docker/.env
command: ['node', './dist/src/main.js']
networks:
- evolution-net
expose:
- 8080
volumes:
evolution_instances:
evolution_store:
evolution_store:
networks:
default:
name: evolution-net

View File

@ -1,6 +1,6 @@
{
"name": "evolution-api",
"version": "1.2.0",
"version": "1.2.1",
"description": "Rest api for communication with WhatsApp",
"main": "./dist/src/main.js",
"scripts": {

View File

@ -43,6 +43,12 @@ export class ChatwootService {
this.logger.verbose('message cache saved');
}
private clearMessageCache() {
this.logger.verbose('clear message cache');
this.messageCache.clear();
this.saveMessageCache();
}
private async getProvider(instance: InstanceDto) {
this.logger.verbose('get provider to instance: ' + instance.instanceName);
try {
@ -258,6 +264,7 @@ export class ChatwootService {
inboxId: number,
isGroup: boolean,
name?: string,
avatar_url?: string,
) {
this.logger.verbose('create contact to instance: ' + instance.instanceName);
@ -275,6 +282,7 @@ export class ChatwootService {
inbox_id: inboxId,
name: name || phoneNumber,
phone_number: `+${phoneNumber}`,
avatar_url: avatar_url,
};
} else {
this.logger.verbose('create contact group in chatwoot');
@ -282,6 +290,7 @@ export class ChatwootService {
inbox_id: inboxId,
name: name || phoneNumber,
identifier: phoneNumber,
avatar_url: avatar_url,
};
}
@ -404,34 +413,67 @@ export class ChatwootService {
nameContact = `${group.subject} (GROUP)`;
this.logger.verbose('find or create participant in chatwoot');
const participant =
(await this.findContact(instance, body.key.participant.split('@')[0])) ||
((await this.createContact(
const picture_url = await this.waMonitor.waInstances[
instance.instanceName
].profilePicture(body.key.participant.split('@')[0]);
const findParticipant = await this.findContact(
instance,
body.key.participant.split('@')[0],
);
if (findParticipant) {
await this.updateContact(instance, findParticipant.id, {
name: nameContact,
avatar_url: picture_url.profilePictureUrl || null,
});
} else {
await this.createContact(
instance,
body.key.participant.split('@')[0],
filterInbox.id,
false,
body.pushName || body.key.participant.split('@')[0],
)) as any);
isGroup,
nameContact,
picture_url.profilePictureUrl || null,
);
}
}
this.logger.verbose('find or create contact in chatwoot');
const contact =
(await this.findContact(instance, chatId)) ||
((await this.createContact(
const picture_url = await this.waMonitor.waInstances[
instance.instanceName
].profilePicture(chatId);
const findContact = await this.findContact(instance, chatId);
let contact: any;
if (findContact) {
contact = await this.updateContact(instance, findContact.id, {
name: nameContact,
avatar_url: picture_url.profilePictureUrl || null,
});
} else {
contact = await this.createContact(
instance,
chatId,
filterInbox.id,
isGroup,
nameContact,
)) as any);
picture_url.profilePictureUrl || null,
);
}
if (!contact) {
this.logger.warn('contact not found');
return null;
}
const contactId = contact.id || contact.payload.contact.id;
console.log(contact);
const contactId = contact.payload.id || contact.payload.contact.id;
if (!body.key.fromMe && contact.name === chatId && nameContact !== chatId) {
this.logger.verbose('update contact name in chatwoot');
@ -968,6 +1010,9 @@ export class ChatwootService {
return { message: 'bot' };
}
this.logger.verbose('clear cache');
this.clearMessageCache();
this.logger.verbose('Format message to send');
let formatText: string;
if (senderName === null || senderName === undefined) {
@ -1124,6 +1169,7 @@ export class ChatwootService {
}
if (event === 'messages.upsert') {
console.log(body);
this.logger.verbose('event messages.upsert');
if (body.key.remoteJid === 'status@broadcast') {