mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-25 01:48:39 -06:00
Merge branch 'release/1.2.1'
This commit is contained in:
commit
5667bceaab
@ -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
|
### Features
|
||||||
|
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
version: '3.3'
|
version: '3.3'
|
||||||
|
|
||||||
networks:
|
|
||||||
evolution-net:
|
|
||||||
driver: bridge
|
|
||||||
|
|
||||||
services:
|
services:
|
||||||
mongodb:
|
mongodb:
|
||||||
container_name: mongodb
|
container_name: mongodb
|
||||||
@ -24,6 +20,24 @@ services:
|
|||||||
expose:
|
expose:
|
||||||
- 27017
|
- 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:
|
volumes:
|
||||||
evolution_mongodb_data:
|
evolution_mongodb_data:
|
||||||
evolution_mongodb_configdb:
|
evolution_mongodb_configdb:
|
||||||
|
|
||||||
|
networks:
|
||||||
|
default:
|
||||||
|
name: evolution-net
|
||||||
|
|
@ -1,9 +1,5 @@
|
|||||||
version: '3.3'
|
version: '3.3'
|
||||||
|
|
||||||
networks:
|
|
||||||
evolution-net:
|
|
||||||
driver: bridge
|
|
||||||
|
|
||||||
services:
|
services:
|
||||||
redis:
|
redis:
|
||||||
image: redis:latest
|
image: redis:latest
|
||||||
@ -16,8 +12,17 @@ services:
|
|||||||
- evolution_redis:/data
|
- evolution_redis:/data
|
||||||
ports:
|
ports:
|
||||||
- 6379:6379
|
- 6379:6379
|
||||||
networks:
|
|
||||||
- evolution-net
|
rebrow:
|
||||||
|
image: marian/rebrow
|
||||||
|
ports:
|
||||||
|
- 5001:5001
|
||||||
|
links:
|
||||||
|
- redis
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
evolution_redis:
|
evolution_redis:
|
||||||
|
|
||||||
|
networks:
|
||||||
|
default:
|
||||||
|
name: evolution-net
|
||||||
|
72
docker-compose-full.yaml
Normal file
72
docker-compose-full.yaml
Normal 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
|
||||||
|
|
@ -1,9 +1,5 @@
|
|||||||
version: '3.3'
|
version: '3.3'
|
||||||
|
|
||||||
networks:
|
|
||||||
evolution-net:
|
|
||||||
driver: bridge
|
|
||||||
|
|
||||||
services:
|
services:
|
||||||
api:
|
api:
|
||||||
container_name: evolution_api
|
container_name: evolution_api
|
||||||
@ -17,11 +13,14 @@ services:
|
|||||||
env_file:
|
env_file:
|
||||||
- ./Docker/.env
|
- ./Docker/.env
|
||||||
command: ['node', './dist/src/main.js']
|
command: ['node', './dist/src/main.js']
|
||||||
networks:
|
|
||||||
- evolution-net
|
|
||||||
expose:
|
expose:
|
||||||
- 8080
|
- 8080
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
evolution_instances:
|
evolution_instances:
|
||||||
evolution_store:
|
evolution_store:
|
||||||
|
|
||||||
|
networks:
|
||||||
|
default:
|
||||||
|
name: evolution-net
|
||||||
|
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "evolution-api",
|
"name": "evolution-api",
|
||||||
"version": "1.2.0",
|
"version": "1.2.1",
|
||||||
"description": "Rest api for communication with WhatsApp",
|
"description": "Rest api for communication with WhatsApp",
|
||||||
"main": "./dist/src/main.js",
|
"main": "./dist/src/main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
@ -43,6 +43,12 @@ export class ChatwootService {
|
|||||||
this.logger.verbose('message cache saved');
|
this.logger.verbose('message cache saved');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private clearMessageCache() {
|
||||||
|
this.logger.verbose('clear message cache');
|
||||||
|
this.messageCache.clear();
|
||||||
|
this.saveMessageCache();
|
||||||
|
}
|
||||||
|
|
||||||
private async getProvider(instance: InstanceDto) {
|
private async getProvider(instance: InstanceDto) {
|
||||||
this.logger.verbose('get provider to instance: ' + instance.instanceName);
|
this.logger.verbose('get provider to instance: ' + instance.instanceName);
|
||||||
try {
|
try {
|
||||||
@ -258,6 +264,7 @@ export class ChatwootService {
|
|||||||
inboxId: number,
|
inboxId: number,
|
||||||
isGroup: boolean,
|
isGroup: boolean,
|
||||||
name?: string,
|
name?: string,
|
||||||
|
avatar_url?: string,
|
||||||
) {
|
) {
|
||||||
this.logger.verbose('create contact to instance: ' + instance.instanceName);
|
this.logger.verbose('create contact to instance: ' + instance.instanceName);
|
||||||
|
|
||||||
@ -275,6 +282,7 @@ export class ChatwootService {
|
|||||||
inbox_id: inboxId,
|
inbox_id: inboxId,
|
||||||
name: name || phoneNumber,
|
name: name || phoneNumber,
|
||||||
phone_number: `+${phoneNumber}`,
|
phone_number: `+${phoneNumber}`,
|
||||||
|
avatar_url: avatar_url,
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
this.logger.verbose('create contact group in chatwoot');
|
this.logger.verbose('create contact group in chatwoot');
|
||||||
@ -282,6 +290,7 @@ export class ChatwootService {
|
|||||||
inbox_id: inboxId,
|
inbox_id: inboxId,
|
||||||
name: name || phoneNumber,
|
name: name || phoneNumber,
|
||||||
identifier: phoneNumber,
|
identifier: phoneNumber,
|
||||||
|
avatar_url: avatar_url,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -404,34 +413,67 @@ export class ChatwootService {
|
|||||||
nameContact = `${group.subject} (GROUP)`;
|
nameContact = `${group.subject} (GROUP)`;
|
||||||
|
|
||||||
this.logger.verbose('find or create participant in chatwoot');
|
this.logger.verbose('find or create participant in chatwoot');
|
||||||
const participant =
|
|
||||||
(await this.findContact(instance, body.key.participant.split('@')[0])) ||
|
const picture_url = await this.waMonitor.waInstances[
|
||||||
((await this.createContact(
|
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,
|
instance,
|
||||||
body.key.participant.split('@')[0],
|
body.key.participant.split('@')[0],
|
||||||
filterInbox.id,
|
filterInbox.id,
|
||||||
false,
|
isGroup,
|
||||||
body.pushName || body.key.participant.split('@')[0],
|
nameContact,
|
||||||
)) as any);
|
picture_url.profilePictureUrl || null,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.logger.verbose('find or create contact in chatwoot');
|
this.logger.verbose('find or create contact in chatwoot');
|
||||||
const contact =
|
|
||||||
(await this.findContact(instance, chatId)) ||
|
const picture_url = await this.waMonitor.waInstances[
|
||||||
((await this.createContact(
|
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,
|
instance,
|
||||||
chatId,
|
chatId,
|
||||||
filterInbox.id,
|
filterInbox.id,
|
||||||
isGroup,
|
isGroup,
|
||||||
nameContact,
|
nameContact,
|
||||||
)) as any);
|
picture_url.profilePictureUrl || null,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (!contact) {
|
if (!contact) {
|
||||||
this.logger.warn('contact not found');
|
this.logger.warn('contact not found');
|
||||||
return null;
|
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) {
|
if (!body.key.fromMe && contact.name === chatId && nameContact !== chatId) {
|
||||||
this.logger.verbose('update contact name in chatwoot');
|
this.logger.verbose('update contact name in chatwoot');
|
||||||
@ -968,6 +1010,9 @@ export class ChatwootService {
|
|||||||
return { message: 'bot' };
|
return { message: 'bot' };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.logger.verbose('clear cache');
|
||||||
|
this.clearMessageCache();
|
||||||
|
|
||||||
this.logger.verbose('Format message to send');
|
this.logger.verbose('Format message to send');
|
||||||
let formatText: string;
|
let formatText: string;
|
||||||
if (senderName === null || senderName === undefined) {
|
if (senderName === null || senderName === undefined) {
|
||||||
@ -1124,6 +1169,7 @@ export class ChatwootService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (event === 'messages.upsert') {
|
if (event === 'messages.upsert') {
|
||||||
|
console.log(body);
|
||||||
this.logger.verbose('event messages.upsert');
|
this.logger.verbose('event messages.upsert');
|
||||||
|
|
||||||
if (body.key.remoteJid === 'status@broadcast') {
|
if (body.key.remoteJid === 'status@broadcast') {
|
||||||
|
Loading…
Reference in New Issue
Block a user