mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-12-20 12:22:21 -06:00
feat: send media with form-data
This commit is contained in:
@@ -28,27 +28,27 @@ export class SendMessageController {
|
||||
return await this.waMonitor.waInstances[instanceName].textMessage(data);
|
||||
}
|
||||
|
||||
public async sendMedia({ instanceName }: InstanceDto, data: SendMediaDto) {
|
||||
public async sendMedia({ instanceName }: InstanceDto, data: SendMediaDto, file?: any) {
|
||||
if (isBase64(data?.media) && !data?.fileName && data?.mediatype === 'document') {
|
||||
throw new BadRequestException('For base64 the file name must be informed.');
|
||||
}
|
||||
|
||||
if (isURL(data?.media) || isBase64(data?.media)) {
|
||||
return await this.waMonitor.waInstances[instanceName].mediaMessage(data);
|
||||
if (file || isURL(data?.media) || isBase64(data?.media)) {
|
||||
return await this.waMonitor.waInstances[instanceName].mediaMessage(data, file);
|
||||
}
|
||||
throw new BadRequestException('Owned media must be a url or base64');
|
||||
}
|
||||
|
||||
public async sendSticker({ instanceName }: InstanceDto, data: SendStickerDto) {
|
||||
if (isURL(data.sticker) || isBase64(data.sticker)) {
|
||||
return await this.waMonitor.waInstances[instanceName].mediaSticker(data);
|
||||
public async sendSticker({ instanceName }: InstanceDto, data: SendStickerDto, file?: any) {
|
||||
if (file || isURL(data.sticker) || isBase64(data.sticker)) {
|
||||
return await this.waMonitor.waInstances[instanceName].mediaSticker(data, file);
|
||||
}
|
||||
throw new BadRequestException('Owned media must be a url or base64');
|
||||
}
|
||||
|
||||
public async sendWhatsAppAudio({ instanceName }: InstanceDto, data: SendAudioDto) {
|
||||
if (isURL(data.audio) || isBase64(data.audio)) {
|
||||
return await this.waMonitor.waInstances[instanceName].audioWhatsapp(data);
|
||||
public async sendWhatsAppAudio({ instanceName }: InstanceDto, data: SendAudioDto, file?: any) {
|
||||
if (file || isURL(data.audio) || isBase64(data.audio)) {
|
||||
return await this.waMonitor.waInstances[instanceName].audioWhatsapp(data, file);
|
||||
}
|
||||
throw new BadRequestException('Owned media must be a url or base64');
|
||||
}
|
||||
@@ -80,7 +80,7 @@ export class SendMessageController {
|
||||
return await this.waMonitor.waInstances[instanceName].pollMessage(data);
|
||||
}
|
||||
|
||||
public async sendStatus({ instanceName }: InstanceDto, data: SendStatusDto) {
|
||||
return await this.waMonitor.waInstances[instanceName].statusMessage(data);
|
||||
public async sendStatus({ instanceName }: InstanceDto, data: SendStatusDto, file?: any) {
|
||||
return await this.waMonitor.waInstances[instanceName].statusMessage(data, file);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user