From 12f7577d79c54106bc42558de1a6ae4d1f28a3c6 Mon Sep 17 00:00:00 2001 From: Enzo William Date: Wed, 11 Mar 2026 15:48:15 -0300 Subject: [PATCH 1/2] fix: mentionsEveryOne always active even when set to false - Changed truthy check to strict equality (=== true) to properly handle string values like "false" sent by clients (e.g., n8n) - Fixed validation schema property name from 'everyOne' to 'mentionsEveryOne' to match DTO and service code Fixes #2431 Co-Authored-By: Claude Opus 4.5 --- .../whatsapp/whatsapp.baileys.service.ts | 2 +- src/validate/message.schema.ts | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts b/src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts index 60e857fcc..12879d6d4 100644 --- a/src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts +++ b/src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts @@ -2372,7 +2372,7 @@ export class BaileysStartupService extends ChannelStartupService { throw new NotFoundException('Group not found'); } - if (options?.mentionsEveryOne) { + if (options?.mentionsEveryOne === true) { mentions = group.participants.map((participant) => participant.id); } else if (options?.mentioned?.length) { mentions = options.mentioned.map((mention) => { diff --git a/src/validate/message.schema.ts b/src/validate/message.schema.ts index d514c6199..d4771331e 100644 --- a/src/validate/message.schema.ts +++ b/src/validate/message.schema.ts @@ -77,7 +77,7 @@ export const textMessageSchema: JSONSchema7 = { description: 'Enter a value in milliseconds', }, quoted: { ...quotedOptionsSchema }, - everyOne: { type: 'boolean', enum: [true, false] }, + mentionsEveryOne: { type: 'boolean', enum: [true, false] }, mentioned: { type: 'array', minItems: 1, @@ -107,7 +107,7 @@ export const mediaMessageSchema: JSONSchema7 = { description: 'Enter a value in milliseconds', }, quoted: { ...quotedOptionsSchema }, - everyOne: { type: 'boolean', enum: [true, false] }, + mentionsEveryOne: { type: 'boolean', enum: [true, false] }, mentioned: { type: 'array', minItems: 1, @@ -133,7 +133,7 @@ export const ptvMessageSchema: JSONSchema7 = { description: 'Enter a value in milliseconds', }, quoted: { ...quotedOptionsSchema }, - everyOne: { type: 'boolean', enum: [true, false] }, + mentionsEveryOne: { type: 'boolean', enum: [true, false] }, mentioned: { type: 'array', minItems: 1, @@ -159,7 +159,7 @@ export const audioMessageSchema: JSONSchema7 = { description: 'Enter a value in milliseconds', }, quoted: { ...quotedOptionsSchema }, - everyOne: { type: 'boolean', enum: [true, false] }, + mentionsEveryOne: { type: 'boolean', enum: [true, false] }, mentioned: { type: 'array', minItems: 1, @@ -209,7 +209,7 @@ export const stickerMessageSchema: JSONSchema7 = { description: 'Enter a value in milliseconds', }, quoted: { ...quotedOptionsSchema }, - everyOne: { type: 'boolean', enum: [true, false] }, + mentionsEveryOne: { type: 'boolean', enum: [true, false] }, mentioned: { type: 'array', minItems: 1, @@ -238,7 +238,7 @@ export const locationMessageSchema: JSONSchema7 = { description: 'Enter a value in milliseconds', }, quoted: { ...quotedOptionsSchema }, - everyOne: { type: 'boolean', enum: [true, false] }, + mentionsEveryOne: { type: 'boolean', enum: [true, false] }, mentioned: { type: 'array', minItems: 1, @@ -325,7 +325,7 @@ export const pollMessageSchema: JSONSchema7 = { description: 'Enter a value in milliseconds', }, quoted: { ...quotedOptionsSchema }, - everyOne: { type: 'boolean', enum: [true, false] }, + mentionsEveryOne: { type: 'boolean', enum: [true, false] }, mentioned: { type: 'array', minItems: 1, @@ -382,7 +382,7 @@ export const listMessageSchema: JSONSchema7 = { description: 'Enter a value in milliseconds', }, quoted: { ...quotedOptionsSchema }, - everyOne: { type: 'boolean', enum: [true, false] }, + mentionsEveryOne: { type: 'boolean', enum: [true, false] }, mentioned: { type: 'array', minItems: 1, @@ -433,7 +433,7 @@ export const buttonsMessageSchema: JSONSchema7 = { description: 'Enter a value in milliseconds', }, quoted: { ...quotedOptionsSchema }, - everyOne: { type: 'boolean', enum: [true, false] }, + mentionsEveryOne: { type: 'boolean', enum: [true, false] }, mentioned: { type: 'array', minItems: 1, From a68289dbd655a07c5fdecac15aad0e591b897860 Mon Sep 17 00:00:00 2001 From: Enzo William Date: Wed, 11 Mar 2026 16:00:23 -0300 Subject: [PATCH 2/2] fix: normalize fileName property to handle case-insensitivity The sendMedia endpoint had an inconsistency where: - For images: only `filename` (lowercase) worked - For documents/videos: only `fileName` (camelCase) worked This was caused by the code only checking `data.fileName` without considering that users might send `filename` (lowercase) in the JSON payload. This fix normalizes the property name at the beginning of the mediaMessage method in all three channel services: - whatsapp.baileys.service.ts - evolution.channel.service.ts - whatsapp.business.service.ts Now both `fileName` and `filename` are accepted for all media types. Closes #2459 Co-Authored-By: Claude Opus 4.5 --- .../channel/evolution/evolution.channel.service.ts | 6 +++++- .../integrations/channel/meta/whatsapp.business.service.ts | 6 +++++- .../channel/whatsapp/whatsapp.baileys.service.ts | 6 +++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/api/integrations/channel/evolution/evolution.channel.service.ts b/src/api/integrations/channel/evolution/evolution.channel.service.ts index 87bea08e6..3c09d6994 100644 --- a/src/api/integrations/channel/evolution/evolution.channel.service.ts +++ b/src/api/integrations/channel/evolution/evolution.channel.service.ts @@ -597,7 +597,11 @@ export class EvolutionStartupService extends ChannelStartupService { } public async mediaMessage(data: SendMediaDto, file?: any, isIntegration = false) { - const mediaData: SendMediaDto = { ...data }; + const mediaData: SendMediaDto = { + ...data, + // Normalize filename to fileName (handle case-insensitivity) + fileName: data.fileName || (data as any).filename, + }; if (file) mediaData.media = file.buffer.toString('base64'); diff --git a/src/api/integrations/channel/meta/whatsapp.business.service.ts b/src/api/integrations/channel/meta/whatsapp.business.service.ts index 1e4808c15..3acd2b361 100644 --- a/src/api/integrations/channel/meta/whatsapp.business.service.ts +++ b/src/api/integrations/channel/meta/whatsapp.business.service.ts @@ -1287,7 +1287,11 @@ export class BusinessStartupService extends ChannelStartupService { } public async mediaMessage(data: SendMediaDto, file?: any, isIntegration = false) { - const mediaData: SendMediaDto = { ...data }; + const mediaData: SendMediaDto = { + ...data, + // Normalize filename to fileName (handle case-insensitivity) + fileName: data.fileName || (data as any).filename, + }; if (file) mediaData.media = file.buffer.toString('base64'); diff --git a/src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts b/src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts index 12879d6d4..308bcc492 100644 --- a/src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts +++ b/src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts @@ -2979,7 +2979,11 @@ export class BaileysStartupService extends ChannelStartupService { } public async mediaMessage(data: SendMediaDto, file?: any, isIntegration = false) { - const mediaData: SendMediaDto = { ...data }; + const mediaData: SendMediaDto = { + ...data, + // Normalize filename to fileName (handle case-insensitivity) + fileName: data.fileName || (data as any).filename, + }; if (file) mediaData.media = file.buffer.toString('base64');