Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -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,
};
Comment on lines 2981 to +2986
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Overriding fileName after spreading may mask an existing, intentionally empty fileName value.

If data.fileName is an empty string (or another falsy-but-valid value), this will incorrectly fall back to (data as any).filename. Prefer checking only for undefined, e.g. fileName: data.fileName ?? (data as any).filename, so intentional empty values are preserved.

Suggested change
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,
};
public async mediaMessage(data: SendMediaDto, file?: any, isIntegration = false) {
const mediaData: SendMediaDto = {
...data,
// Normalize filename to fileName (handle case-insensitivity) while preserving intentional empty values
fileName: data.fileName ?? (data as any).filename,
};


if (file) mediaData.media = file.buffer.toString('base64');

Expand Down
18 changes: 9 additions & 9 deletions src/validate/message.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down