hotfix_group_update

This commit is contained in:
pedro-php 2025-05-30 08:31:07 -03:00
parent 8ab198fe9e
commit 7968057a82
11 changed files with 40 additions and 33 deletions

View File

@ -1,8 +1,5 @@
ENVIROMNENT="dev"
SERVER_TYPE=http
SERVER_PORT=8080
MIRROR_PORT=11233
# Server URL - Set your application url
SERVER_URL=http://localhost:8080
@ -181,13 +178,13 @@ WEBHOOK_EVENTS_ERRORS=false
WEBHOOK_EVENTS_ERRORS_WEBHOOK=
# Name that will be displayed on smartphone connection
CONFIG_SESSION_PHONE_CLIENT='Whizapp'
CONFIG_SESSION_PHONE_CLIENT=Whizapp
# Browser Name = Chrome | Firefox | Edge | Opera | Safari
CONFIG_SESSION_PHONE_NAME=Chrome
# Whatsapp Web version for baileys channel
# https://web.whatsapp.com/check-update?version=0&platform=web
CONFIG_SESSION_PHONE_VERSION=2.3000.1023005435
CONFIG_SESSION_PHONE_VERSION=2.3000.1020885143
# Set qrcode display limit
QRCODE_LIMIT=30

View File

@ -44,7 +44,7 @@ services:
- RABBITMQ_EVENTS_CHATS_UPDATE=false
- RABBITMQ_EVENTS_CHATS_DELETE=false
- RABBITMQ_EVENTS_GROUPS_UPSERT=false
- RABBITMQ_EVENTS_GROUP_UPDATE=false
- RABBITMQ_EVENTS_GROUPS_UPDATE=false
- RABBITMQ_EVENTS_GROUP_PARTICIPANTS_UPDATE=false
- RABBITMQ_EVENTS_CONNECTION_UPDATE=true
- RABBITMQ_EVENTS_CALL=false

View File

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

File diff suppressed because one or more lines are too long

View File

@ -1368,7 +1368,6 @@ export class BaileysStartupService extends ChannelStartupService {
if (isMedia && this.localWebhook.webhookBase64) {
try {
let buffer: Buffer = null;
console.dir({ received }, { depth: null });
if (
(received.message.stickerMessage &&
received.message.stickerMessage.url === 'https://web.whatsapp.net') ||
@ -1415,7 +1414,6 @@ export class BaileysStartupService extends ChannelStartupService {
}
}
console.dir({ webhookMessage: messageRaw }, { depth: null });
this.logger.log(messageRaw);
this.sendDataWebhook(Events.MESSAGES_UPSERT, messageRaw);
@ -1653,12 +1651,13 @@ export class BaileysStartupService extends ChannelStartupService {
private readonly groupHandler = {
'groups.upsert': (groupMetadata: GroupMetadata[]) => {
console.dir(groupMetadata, { depth: null });
console.dir({groupMetadata}, { depth: null });
this.sendDataWebhook(Events.GROUPS_UPSERT, groupMetadata);
},
'groups.update': (groupMetadataUpdate: Partial<GroupMetadata>[]) => {
console.dir(groupMetadataUpdate, { depth: null });
console.dir({groupMetadataUpdate}, { depth: null });
console.dir("1-groupMetadataUpdate");
this.sendDataWebhook(Events.GROUPS_UPDATE, groupMetadataUpdate);
groupMetadataUpdate.forEach((group) => {

View File

@ -142,7 +142,7 @@ export class EventController {
'CHATS_UPDATE',
'CHATS_DELETE',
'GROUPS_UPSERT',
'GROUP_UPDATE',
'GROUPS_UPDATE',
'GROUP_PARTICIPANTS_UPDATE',
'CONNECTION_UPDATE',
'LABELS_EDIT',

View File

@ -113,6 +113,7 @@ export class EventManager {
local?: boolean;
integration?: string[];
}): Promise<void> {
if(eventData.event === 'groups.update') console.dir(3);
await this.websocket.emit(eventData);
await this.rabbitmq.emit(eventData);
await this.nats.emit(eventData);

View File

@ -65,12 +65,13 @@ export class WebhookController extends EventController implements EventControlle
local,
integration,
}: EmitData): Promise<void> {
if(event === 'groups.update')console.dir(4);
if (integration && !integration.includes('webhook')) {
return;
}
if(event === 'groups.update')console.dir(5);
const instance = (await this.get(instanceName)) as wa.LocalWebHook;
if(event === 'groups.update')console.dir(6);
const webhookConfig = configService.get<Webhook>('WEBHOOK');
const webhookLocal = instance?.events;
const webhookHeaders = instance?.headers;
@ -89,34 +90,42 @@ export class WebhookController extends EventController implements EventControlle
server_url: serverUrl,
apikey: apiKey,
};
if(event === 'groups.update')console.dir(7);
if (local && instance?.enabled) {
if(event === 'groups.update')console.dir(7.1);
console.dir({webhookLocal, we})
if (Array.isArray(webhookLocal) && webhookLocal.includes(we)) {
let baseURL: string;
if(event === 'groups.update')console.dir(7.2);
if (instance?.webhookByEvents) {
if(event === 'groups.update')console.dir(7.21);
baseURL = `${instance?.url}/${transformedWe}`;
} else {
if(event === 'groups.update')console.dir(7.22);
baseURL = instance?.url;
}
if(event === 'groups.update')console.dir(7.3);
if (enabledLog) {
const logData = {
local: `${origin}.sendData-Webhook`,
url: baseURL,
...webhookData,
};
if(event === 'groups.update')console.dir(7.4);
this.logger.log(logData);
}
try {
if(event === 'groups.update')console.dir(7.5);
if (instance?.enabled && regex.test(instance.url)) {
if(event === 'groups.update')console.dir(7.6);
const httpService = axios.create({
baseURL,
headers: webhookHeaders as Record<string, string> | undefined,
});
if(event === 'groups.update')console.dir(7.7);
console.dir({url:`${origin}.sendData-Webhook`, baseURL, serverUrl}, {depth: null})
if(event === 'groups.update')console.dir(7.8);
await this.retryWebhookRequest(httpService, webhookData, `${origin}.sendData-Webhook`, baseURL, serverUrl);
}
} catch (error) {
@ -135,7 +144,7 @@ export class WebhookController extends EventController implements EventControlle
}
}
}
if(event === 'groups.update')console.dir(8);
if (webhookConfig.GLOBAL?.ENABLED) {
if (webhookConfig.EVENTS[we]) {
let globalURL = webhookConfig.GLOBAL.URL;
@ -182,6 +191,7 @@ export class WebhookController extends EventController implements EventControlle
}
}
}
if(event === 'groups.update')console.dir(9)
}
private async retryWebhookRequest(

View File

@ -439,7 +439,7 @@ export class ChannelStartupService {
const expose = this.configService.get<Auth>('AUTHENTICATION').EXPOSE_IN_FETCH_INSTANCES;
const instanceApikey = this.token || 'Apikey not found';
if(event === Events.GROUPS_UPDATE )console.dir(2);
await eventManager.emit({
instanceName: this.instance.name,
origin: ChannelStartupService.name,

View File

@ -85,7 +85,7 @@ export type EventsRabbitmq = {
LABELS_EDIT: boolean;
LABELS_ASSOCIATION: boolean;
GROUPS_UPSERT: boolean;
GROUP_UPDATE: boolean;
GROUPS_UPDATE: boolean;
GROUP_PARTICIPANTS_UPDATE: boolean;
CALL: boolean;
TYPEBOT_START: boolean;
@ -154,7 +154,7 @@ export type EventsWebhook = {
LABELS_EDIT: boolean;
LABELS_ASSOCIATION: boolean;
GROUPS_UPSERT: boolean;
GROUP_UPDATE: boolean;
GROUPS_UPDATE: boolean;
GROUP_PARTICIPANTS_UPDATE: boolean;
CALL: boolean;
TYPEBOT_START: boolean;
@ -187,7 +187,7 @@ export type EventsPusher = {
LABELS_EDIT: boolean;
LABELS_ASSOCIATION: boolean;
GROUPS_UPSERT: boolean;
GROUP_UPDATE: boolean;
GROUPS_UPDATE: boolean;
GROUP_PARTICIPANTS_UPDATE: boolean;
CALL: boolean;
TYPEBOT_START: boolean;
@ -396,7 +396,7 @@ export class ConfigService {
LABELS_EDIT: process.env?.RABBITMQ_EVENTS_LABELS_EDIT === 'true',
LABELS_ASSOCIATION: process.env?.RABBITMQ_EVENTS_LABELS_ASSOCIATION === 'true',
GROUPS_UPSERT: process.env?.RABBITMQ_EVENTS_GROUPS_UPSERT === 'true',
GROUP_UPDATE: process.env?.RABBITMQ_EVENTS_GROUPS_UPDATE === 'true',
GROUPS_UPDATE: process.env?.RABBITMQ_EVENTS_GROUPS_UPDATE === 'true',
GROUP_PARTICIPANTS_UPDATE: process.env?.RABBITMQ_EVENTS_GROUP_PARTICIPANTS_UPDATE === 'true',
CALL: process.env?.RABBITMQ_EVENTS_CALL === 'true',
TYPEBOT_START: process.env?.RABBITMQ_EVENTS_TYPEBOT_START === 'true',
@ -433,7 +433,7 @@ export class ConfigService {
LABELS_EDIT: process.env?.NATS_EVENTS_LABELS_EDIT === 'true',
LABELS_ASSOCIATION: process.env?.NATS_EVENTS_LABELS_ASSOCIATION === 'true',
GROUPS_UPSERT: process.env?.NATS_EVENTS_GROUPS_UPSERT === 'true',
GROUP_UPDATE: process.env?.NATS_EVENTS_GROUPS_UPDATE === 'true',
GROUPS_UPDATE: process.env?.NATS_EVENTS_GROUPS_UPDATE === 'true',
GROUP_PARTICIPANTS_UPDATE: process.env?.NATS_EVENTS_GROUP_PARTICIPANTS_UPDATE === 'true',
CALL: process.env?.NATS_EVENTS_CALL === 'true',
TYPEBOT_START: process.env?.NATS_EVENTS_TYPEBOT_START === 'true',
@ -485,7 +485,7 @@ export class ConfigService {
LABELS_EDIT: process.env?.PUSHER_EVENTS_LABELS_EDIT === 'true',
LABELS_ASSOCIATION: process.env?.PUSHER_EVENTS_LABELS_ASSOCIATION === 'true',
GROUPS_UPSERT: process.env?.PUSHER_EVENTS_GROUPS_UPSERT === 'true',
GROUP_UPDATE: process.env?.PUSHER_EVENTS_GROUPS_UPDATE === 'true',
GROUPS_UPDATE: process.env?.PUSHER_EVENTS_GROUPS_UPDATE === 'true',
GROUP_PARTICIPANTS_UPDATE: process.env?.PUSHER_EVENTS_GROUP_PARTICIPANTS_UPDATE === 'true',
CALL: process.env?.PUSHER_EVENTS_CALL === 'true',
TYPEBOT_START: process.env?.PUSHER_EVENTS_TYPEBOT_START === 'true',
@ -542,7 +542,7 @@ export class ConfigService {
LABELS_EDIT: process.env?.WEBHOOK_EVENTS_LABELS_EDIT === 'true',
LABELS_ASSOCIATION: process.env?.WEBHOOK_EVENTS_LABELS_ASSOCIATION === 'true',
GROUPS_UPSERT: process.env?.WEBHOOK_EVENTS_GROUPS_UPSERT === 'true',
GROUP_UPDATE: process.env?.WEBHOOK_EVENTS_GROUPS_UPDATE === 'true',
GROUPS_UPDATE: process.env?.WEBHOOK_EVENTS_GROUPS_UPDATE === 'true',
GROUP_PARTICIPANTS_UPDATE: process.env?.WEBHOOK_EVENTS_GROUP_PARTICIPANTS_UPDATE === 'true',
CALL: process.env?.WEBHOOK_EVENTS_CALL === 'true',
TYPEBOT_START: process.env?.WEBHOOK_EVENTS_TYPEBOT_START === 'true',

View File

@ -78,7 +78,7 @@ export const instanceSchema: JSONSchema7 = {
'CHATS_UPDATE',
'CHATS_DELETE',
'GROUPS_UPSERT',
'GROUP_UPDATE',
'GROUPS_UPDATE',
'GROUP_PARTICIPANTS_UPDATE',
'CONNECTION_UPDATE',
'LABELS_EDIT',
@ -115,7 +115,7 @@ export const instanceSchema: JSONSchema7 = {
'CHATS_UPDATE',
'CHATS_DELETE',
'GROUPS_UPSERT',
'GROUP_UPDATE',
'GROUPS_UPDATE',
'GROUP_PARTICIPANTS_UPDATE',
'CONNECTION_UPDATE',
'LABELS_EDIT',
@ -152,7 +152,7 @@ export const instanceSchema: JSONSchema7 = {
'CHATS_UPDATE',
'CHATS_DELETE',
'GROUPS_UPSERT',
'GROUP_UPDATE',
'GROUPS_UPDATE',
'GROUP_PARTICIPANTS_UPDATE',
'CONNECTION_UPDATE',
'LABELS_EDIT',
@ -189,7 +189,7 @@ export const instanceSchema: JSONSchema7 = {
'CHATS_UPDATE',
'CHATS_DELETE',
'GROUPS_UPSERT',
'GROUP_UPDATE',
'GROUPS_UPDATE',
'GROUP_PARTICIPANTS_UPDATE',
'CONNECTION_UPDATE',
'LABELS_EDIT',