mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-23 17:08:44 -06:00
fix: Corregir manejo de archivo de audio en WhatsApp
This commit is contained in:
parent
83567d6466
commit
59af93251d
@ -483,7 +483,12 @@ export class EvolutionStartupService extends ChannelStartupService {
|
||||
public async audioWhatsapp(data: SendAudioDto, file?: any, isIntegration = false) {
|
||||
const mediaData: SendAudioDto = { ...data };
|
||||
|
||||
if (file) mediaData.audio = file.buffer.toString('base64');
|
||||
if (file?.buffer) {
|
||||
mediaData.audio = file.buffer.toString('base64');
|
||||
} else {
|
||||
console.error("El archivo o buffer no está definido correctamente.");
|
||||
throw new Error("File or buffer is undefined.");
|
||||
}
|
||||
|
||||
const message = await this.processAudio(mediaData.audio, data.number);
|
||||
|
||||
|
@ -1081,7 +1081,13 @@ export class BusinessStartupService extends ChannelStartupService {
|
||||
public async audioWhatsapp(data: SendAudioDto, file?: any, isIntegration = false) {
|
||||
const mediaData: SendAudioDto = { ...data };
|
||||
|
||||
if (file) mediaData.audio = file.buffer.toString('base64');
|
||||
if (file?.buffer) {
|
||||
// Asegurarse de que file y buffer existen antes de usarlos
|
||||
mediaData.audio = file.buffer.toString('base64');
|
||||
} else {
|
||||
console.error('El archivo no tiene buffer o file es undefined');
|
||||
throw new Error('File or buffer is undefined');
|
||||
}
|
||||
|
||||
const message = await this.processAudio(mediaData.audio, data.number);
|
||||
|
||||
|
@ -2574,7 +2574,12 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
public async audioWhatsapp(data: SendAudioDto, file?: any, isIntegration = false) {
|
||||
const mediaData: SendAudioDto = { ...data };
|
||||
|
||||
if (file) mediaData.audio = file.buffer.toString('base64');
|
||||
if (file?.buffer) {
|
||||
mediaData.audio = file.buffer.toString('base64');
|
||||
} else if (!isURL(data.audio) && !isBase64(data.audio)) {
|
||||
console.error('Invalid file or audio source');
|
||||
throw new BadRequestException('File buffer, URL, or base64 audio is required');
|
||||
}
|
||||
|
||||
if (!data?.encoding && data?.encoding !== false) {
|
||||
data.encoding = true;
|
||||
|
Loading…
Reference in New Issue
Block a user