Alteracoes 2025-06-14

This commit is contained in:
Éder Costa 2025-06-14 08:35:37 -03:00
parent fcf6b03b4c
commit 12c993de85
4 changed files with 27 additions and 12 deletions

View File

@ -3,7 +3,7 @@ FROM node:20-alpine AS builder
RUN apk update && \ RUN apk update && \
apk add git ffmpeg wget curl bash openssl apk add git ffmpeg wget curl bash openssl
LABEL version="2.2.3.22" description="Api to control whatsapp features through http requests." LABEL version="2.2.3.24" description="Api to control whatsapp features through http requests."
LABEL maintainer="Davidson Gomes" git="https://github.com/DavidsonGomes" LABEL maintainer="Davidson Gomes" git="https://github.com/DavidsonGomes"
LABEL contact="contato@atendai.com" LABEL contact="contato@atendai.com"

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{ {
"name": "evolution-api", "name": "evolution-api",
"version": "2.2.3.22", "version": "2.2.3.24",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "evolution-api", "name": "evolution-api",
"version": "2.2.3.22", "version": "2.2.3.24",
"license": "Apache-2.0", "license": "Apache-2.0",
"dependencies": { "dependencies": {
"@adiwajshing/keyed-db": "^0.2.4", "@adiwajshing/keyed-db": "^0.2.4",

View File

@ -1,6 +1,6 @@
{ {
"name": "evolution-api", "name": "evolution-api",
"version": "2.2.3.22", "version": "2.2.3.24",
"description": "Rest api for communication with WhatsApp", "description": "Rest api for communication with WhatsApp",
"main": "./dist/main.js", "main": "./dist/main.js",
"type": "commonjs", "type": "commonjs",

View File

@ -647,6 +647,9 @@ export class ChatwootService {
} }
} }
private async _createConversation(instance: InstanceDto, body: any): Promise<number> { private async _createConversation(instance: InstanceDto, body: any): Promise<number> {
const remoteJid = body.key.remoteJid as string; const remoteJid = body.key.remoteJid as string;
const cacheKey = instance.instanceName + ":createConversation-" + remoteJid; const cacheKey = instance.instanceName + ":createConversation-" + remoteJid;
@ -687,9 +690,18 @@ export class ChatwootService {
this.logger.verbose("[_createConversation] Contato encontrado: id=" + contact.id); this.logger.verbose("[_createConversation] Contato encontrado: id=" + contact.id);
} else { } else {
this.logger.verbose("[_createConversation] Contato nao existe, criando..."); this.logger.verbose("[_createConversation] Contato nao existe, criando...");
const isOutgoing = body.key.fromMe;
const senderName = !isOutgoing && body.pushName ? body.pushName : chatId;
const name = isGroup const name = isGroup
? (await this.waMonitor.waInstances[instance.instanceName].client.groupMetadata(chatId)).subject + " (GROUP)" ? (await this.waMonitor.waInstances[instance.instanceName]
: body.pushName || chatId; .client.groupMetadata(chatId)).subject + " (GROUP)"
: senderName;
const pictureUrl = (await this.waMonitor.waInstances[instance.instanceName].profilePicture(chatId)).profilePictureUrl; const pictureUrl = (await this.waMonitor.waInstances[instance.instanceName].profilePicture(chatId)).profilePictureUrl;
contact = await this.createContact( contact = await this.createContact(
instance, instance,
@ -760,13 +772,16 @@ export class ChatwootService {
accountId: this.provider.accountId, accountId: this.provider.accountId,
data: payload, data: payload,
}); });
if (!newConv?.id) {
this.logger.error("[_createConversation] create retornou sem ID"); const displayId = (newConv as any).display_id ?? newConv.id;
throw new Error("Falha ao criar nova conversa: resposta sem ID");
if (!displayId) {
this.logger.error("[_createConversation] create retornou sem DisplayID");
throw new Error("Falha ao criar nova conversa: resposta sem DisplayID");
} }
this.logger.verbose("[_createConversation] Nova conversa criada id=" + newConv.id); this.logger.verbose("[_createConversation] Nova conversa criada DisplayId=" + displayId);
this.cache.set(cacheKey, newConv.id, 5 * 60); this.cache.set(cacheKey, displayId, 5 * 60);
return newConv.id; return displayId;
} catch (err: any) { } catch (err: any) {
this.logger.error("[_createConversation] Erro ao criar conversa: " + err); this.logger.error("[_createConversation] Erro ao criar conversa: " + err);