eovlution_api_hotfix_id_group

This commit is contained in:
pedro-php 2025-06-16 11:04:55 -03:00
parent 16a9d1faf5
commit 1b1eb0356a
11 changed files with 33 additions and 35 deletions

View File

@ -2,7 +2,7 @@ services:
api: api:
container_name: evolution_api_${ENVIROMNENT} container_name: evolution_api_${ENVIROMNENT}
build: . build: .
image: adaptweb/evolution-api:1.7.0 image: adaptweb/evolution-api:1.7.1
restart: always restart: always
depends_on: depends_on:
- redis - redis

View File

@ -236,7 +236,7 @@ export class InstanceController {
autoCreate: instanceData.chatwootAutoCreate !== false, autoCreate: instanceData.chatwootAutoCreate !== false,
}); });
} catch (error) { } catch (error) {
this.logger.log(error); //this.logger.log(error);
} }
return { return {

View File

@ -173,7 +173,7 @@ export class EvolutionStartupService extends ChannelStartupService {
} }
} }
this.logger.log(messageRaw); //this.logger.log(messageRaw);
this.sendDataWebhook(Events.MESSAGES_UPSERT, messageRaw); this.sendDataWebhook(Events.MESSAGES_UPSERT, messageRaw);
@ -498,7 +498,7 @@ export class EvolutionStartupService extends ChannelStartupService {
} }
} }
this.logger.log(messageRaw); // this.logger.log(messageRaw);
this.sendDataWebhook(Events.SEND_MESSAGE, messageRaw); this.sendDataWebhook(Events.SEND_MESSAGE, messageRaw);

View File

@ -514,7 +514,7 @@ export class BusinessStartupService extends ChannelStartupService {
} }
} }
this.logger.log(messageRaw); //this.logger.log(messageRaw);
this.sendDataWebhook(Events.MESSAGES_UPSERT, messageRaw); this.sendDataWebhook(Events.MESSAGES_UPSERT, messageRaw);
@ -953,7 +953,7 @@ export class BusinessStartupService extends ChannelStartupService {
source: 'unknown', source: 'unknown',
}; };
this.logger.log(messageRaw); // this.logger.log(messageRaw);
this.sendDataWebhook(Events.SEND_MESSAGE, messageRaw); this.sendDataWebhook(Events.SEND_MESSAGE, messageRaw);

View File

@ -1306,17 +1306,17 @@ export class BaileysStartupService extends ChannelStartupService {
if (received.key.fromMe === false) { if (received.key.fromMe === false) {
if (msg.status === status[3]) { if (msg.status === status[3]) {
this.logger.log(`Update not read messages ${received.key.remoteJid}`); // this.logger.log(`Update not read messages ${received.key.remoteJid}`);
await this.updateChatUnreadMessages(received.key.remoteJid); await this.updateChatUnreadMessages(received.key.remoteJid);
} else if (msg.status === status[4]) { } else if (msg.status === status[4]) {
this.logger.log(`Update readed messages ${received.key.remoteJid} - ${msg.messageTimestamp}`); // this.logger.log(`Update readed messages ${received.key.remoteJid} - ${msg.messageTimestamp}`);
await this.updateMessagesReadedByTimestamp(received.key.remoteJid, msg.messageTimestamp); await this.updateMessagesReadedByTimestamp(received.key.remoteJid, msg.messageTimestamp);
} }
} else { } else {
// is send message by me // is send message by me
this.logger.log(`Update readed messages ${received.key.remoteJid} - ${msg.messageTimestamp}`); //this.logger.log(`Update readed messages ${received.key.remoteJid} - ${msg.messageTimestamp}`);
await this.updateMessagesReadedByTimestamp(received.key.remoteJid, msg.messageTimestamp); await this.updateMessagesReadedByTimestamp(received.key.remoteJid, msg.messageTimestamp);
} }
@ -1413,7 +1413,7 @@ export class BaileysStartupService extends ChannelStartupService {
} }
} }
this.logger.log(messageRaw); //this.logger.log(messageRaw);
this.sendDataWebhook(Events.MESSAGES_UPSERT, messageRaw); this.sendDataWebhook(Events.MESSAGES_UPSERT, messageRaw);
@ -1484,7 +1484,7 @@ export class BaileysStartupService extends ChannelStartupService {
}, },
'messages.update': async (args: WAMessageUpdate[], settings: any) => { 'messages.update': async (args: WAMessageUpdate[], settings: any) => {
this.logger.log(`Update messages ${JSON.stringify(args, undefined, 2)}`); //this.logger.log(`Update messages ${JSON.stringify(args, undefined, 2)}`);
const readChatToUpdate: Record<string, true> = {}; // {remoteJid: true} const readChatToUpdate: Record<string, true> = {}; // {remoteJid: true}
@ -1587,7 +1587,7 @@ export class BaileysStartupService extends ChannelStartupService {
readChatToUpdate[key.remoteJid] = true; readChatToUpdate[key.remoteJid] = true;
if (status[update.status] === status[4]) { if (status[update.status] === status[4]) {
this.logger.log(`Update as read ${key.remoteJid} - ${findMessage.messageTimestamp}`); //this.logger.log(`Update as read ${key.remoteJid} - ${findMessage.messageTimestamp}`);
this.updateMessagesReadedByTimestamp(key.remoteJid, findMessage.messageTimestamp); this.updateMessagesReadedByTimestamp(key.remoteJid, findMessage.messageTimestamp);
} }
} }
@ -2398,7 +2398,7 @@ export class BaileysStartupService extends ChannelStartupService {
} }
} }
this.logger.log(messageRaw); //this.logger.log(messageRaw);
this.sendDataWebhook(Events.SEND_MESSAGE, messageRaw); this.sendDataWebhook(Events.SEND_MESSAGE, messageRaw);
@ -3382,7 +3382,6 @@ export class BaileysStartupService extends ChannelStartupService {
broadcast: [], broadcast: [],
users: [], users: [],
}; };
data.numbers.forEach((number) => { data.numbers.forEach((number) => {
const jid = createJid(number); const jid = createJid(number);
@ -4252,7 +4251,6 @@ export class BaileysStartupService extends ChannelStartupService {
public async findGroup(id: GroupJid, reply: 'inner' | 'out' = 'out') { public async findGroup(id: GroupJid, reply: 'inner' | 'out' = 'out') {
try { try {
const group = await this.client.groupMetadata(id.groupJid); const group = await this.client.groupMetadata(id.groupJid);
if (!group) { if (!group) {
this.logger.error('Group not found'); this.logger.error('Group not found');
return null; return null;

View File

@ -109,7 +109,7 @@ export class ChatbotController {
) { ) {
if (userMessageDebounce[remoteJid]) { if (userMessageDebounce[remoteJid]) {
userMessageDebounce[remoteJid].message += `\n${content}`; userMessageDebounce[remoteJid].message += `\n${content}`;
this.logger.log('message debounced: ' + userMessageDebounce[remoteJid].message); //this.logger.log('message debounced: ' + userMessageDebounce[remoteJid].message);
clearTimeout(userMessageDebounce[remoteJid].timeoutId); clearTimeout(userMessageDebounce[remoteJid].timeoutId);
} else { } else {
userMessageDebounce[remoteJid] = { userMessageDebounce[remoteJid] = {
@ -120,7 +120,7 @@ export class ChatbotController {
userMessageDebounce[remoteJid].timeoutId = setTimeout(() => { userMessageDebounce[remoteJid].timeoutId = setTimeout(() => {
const myQuestion = userMessageDebounce[remoteJid].message; const myQuestion = userMessageDebounce[remoteJid].message;
this.logger.log('Debounce complete. Processing message: ' + myQuestion); // this.logger.log('Debounce complete. Processing message: ' + myQuestion);
delete userMessageDebounce[remoteJid]; delete userMessageDebounce[remoteJid];
callback(myQuestion); callback(myQuestion);

View File

@ -110,7 +110,7 @@ export class ChatwootService {
await this.waMonitor.waInstances[instance.instanceName].setChatwoot(data); await this.waMonitor.waInstances[instance.instanceName].setChatwoot(data);
if (data.autoCreate) { if (data.autoCreate) {
this.logger.log('Auto create chatwoot instance'); //this.logger.log('Auto create chatwoot instance');
const urlServer = this.configService.get<HttpServer>('SERVER').URL; const urlServer = this.configService.get<HttpServer>('SERVER').URL;
await this.initInstanceChatwoot( await this.initInstanceChatwoot(
@ -185,7 +185,7 @@ export class ChatwootService {
let inboxId: number; let inboxId: number;
this.logger.log('Creating chatwoot inbox'); //this.logger.log('Creating chatwoot inbox');
if (!checkDuplicate) { if (!checkDuplicate) {
const data = { const data = {
type: 'api', type: 'api',
@ -216,15 +216,15 @@ export class ChatwootService {
inboxId = inbox.id; inboxId = inbox.id;
} }
this.logger.log(`Inbox created - inboxId: ${inboxId}`); //this.logger.log(`Inbox created - inboxId: ${inboxId}`);
if (!this.configService.get<Chatwoot>('CHATWOOT').BOT_CONTACT) { if (!this.configService.get<Chatwoot>('CHATWOOT').BOT_CONTACT) {
this.logger.log('Chatwoot bot contact is disabled'); // this.logger.log('Chatwoot bot contact is disabled');
return true; return true;
} }
this.logger.log('Creating chatwoot bot contact'); //this.logger.log('Creating chatwoot bot contact');
const contact = const contact =
(await this.findContact(instance, '123456')) || (await this.findContact(instance, '123456')) ||
((await this.createContact( ((await this.createContact(
@ -242,10 +242,10 @@ export class ChatwootService {
} }
const contactId = contact.id || contact.payload.contact.id; const contactId = contact.id || contact.payload.contact.id;
this.logger.log(`Contact created - contactId: ${contactId}`); //this.logger.log(`Contact created - contactId: ${contactId}`);
if (qrcode) { if (qrcode) {
this.logger.log('QR code enabled'); //this.logger.log('QR code enabled');
const data = { const data = {
contact_id: contactId.toString(), contact_id: contactId.toString(),
inbox_id: inboxId.toString(), inbox_id: inboxId.toString(),
@ -280,7 +280,7 @@ export class ChatwootService {
this.logger.warn('conversation not found'); this.logger.warn('conversation not found');
return null; return null;
} }
this.logger.log('Init message sent'); // this.logger.log('Init message sent');
} }
return true; return true;
@ -1005,7 +1005,7 @@ export class ChatwootService {
} }
if (!this.configService.get<Chatwoot>('CHATWOOT').BOT_CONTACT) { if (!this.configService.get<Chatwoot>('CHATWOOT').BOT_CONTACT) {
this.logger.log('Chatwoot bot contact is disabled'); // this.logger.log('Chatwoot bot contact is disabled');
return true; return true;
} }

View File

@ -162,11 +162,11 @@ export class PusherController extends EventController implements EventController
const pusherLocalEvents = instance.events; const pusherLocalEvents = instance.events;
if (Array.isArray(pusherLocalEvents) && pusherLocalEvents.includes(we)) { if (Array.isArray(pusherLocalEvents) && pusherLocalEvents.includes(we)) {
if (enabledLog) { if (enabledLog) {
this.logger.log({ /* this.logger.log({
local: `${origin}.sendData-Pusher`, local: `${origin}.sendData-Pusher`,
appId: instance.appId, appId: instance.appId,
...pusherData, ...pusherData,
}); }); */
} }
try { try {
const pusher = this.pusherClients[instanceName]; const pusher = this.pusherClients[instanceName];
@ -188,11 +188,11 @@ export class PusherController extends EventController implements EventController
const globalEvents = this.pusherConfig.EVENTS; const globalEvents = this.pusherConfig.EVENTS;
if (globalEvents[we]) { if (globalEvents[we]) {
if (enabledLog) { if (enabledLog) {
this.logger.log({ /* this.logger.log({
local: `${origin}.sendData-Pusher-Global`, local: `${origin}.sendData-Pusher-Global`,
appId: this.pusherConfig.GLOBAL?.APP_ID, appId: this.pusherConfig.GLOBAL?.APP_ID,
...pusherData, ...pusherData,
}); }); */
} }
try { try {
if (this.globalPusherClient) { if (this.globalPusherClient) {

View File

@ -190,13 +190,13 @@ export class WebhookController extends EventController implements EventControlle
while (attempts < maxRetries) { while (attempts < maxRetries) {
try { try {
await httpService.post('', webhookData); await httpService.post('', webhookData);
if (attempts > 0) { /* if (attempts > 0) {
this.logger.log({ this.logger.log({
local: `${origin}`, local: `${origin}`,
message: `Sucesso no envio após ${attempts + 1} tentativas`, message: `Sucesso no envio após ${attempts + 1} tentativas`,
url: baseURL, url: baseURL,
}); });
} } */
return; return;
} catch (error) { } catch (error) {
attempts++; attempts++;

View File

@ -148,12 +148,12 @@ export class WebsocketController extends EventController implements EventControl
this.socket.of(`/${instanceName}`).emit(event, message); this.socket.of(`/${instanceName}`).emit(event, message);
if (logEnabled) { if (logEnabled) {
this.logger.log({ local: `${origin}.sendData-Websocket`, ...message }); // this.logger.log({ local: `${origin}.sendData-Websocket`, ...message });
} }
} }
} catch (err) { } catch (err) {
if (logEnabled) { if (logEnabled) {
this.logger.log(err); // this.logger.log(err);
} }
} }
} }

View File

@ -51,7 +51,7 @@ export function createJid(number: string): string {
.split(':')[0] .split(':')[0]
.split('@')[0]; .split('@')[0];
if (number.includes('-') && number.length >= 24) { if (number.includes('-') && number.length >= 23) {
number = number.replace(/[^\d-]/g, ''); number = number.replace(/[^\d-]/g, '');
return `${number}@g.us`; return `${number}@g.us`;
} }