fix: Added mimetype field when sending media

This commit is contained in:
Davidson Gomes 2023-10-25 10:29:24 -03:00
parent bc70ec8b07
commit 783c00a1d9
6 changed files with 12 additions and 7 deletions

View File

@ -4,6 +4,7 @@
* Adjusts in proxy * Adjusts in proxy
* Adjusts in start session for Typebot * Adjusts in start session for Typebot
* Added mimetype field when sending media
# 1.5.4 (2023-10-09 20:43) # 1.5.4 (2023-10-09 20:43)

View File

@ -1,6 +1,6 @@
FROM node:20.7.0-alpine FROM node:20.7.0-alpine
LABEL version="1.5.4" description="Api to control whatsapp features through http requests." LABEL version="1.5.5" description="Api to control whatsapp features through http requests."
LABEL maintainer="Davidson Gomes" git="https://github.com/DavidsonGomes" LABEL maintainer="Davidson Gomes" git="https://github.com/DavidsonGomes"
LABEL contact="contato@agenciadgcode.com" LABEL contact="contato@agenciadgcode.com"

View File

@ -1,6 +1,6 @@
{ {
"name": "evolution-api", "name": "evolution-api",
"version": "1.5.4", "version": "1.5.5",
"description": "Rest api for communication with WhatsApp", "description": "Rest api for communication with WhatsApp",
"main": "./dist/src/main.js", "main": "./dist/src/main.js",
"scripts": { "scripts": {

View File

@ -25,7 +25,7 @@ info:
</font> </font>
[![Run in Postman](https://run.pstmn.io/button.svg)](https://god.gw.postman.com/run-collection/26869335-5546d063-156b-4529-915f-909dd628c090?action=collection%2Ffork&source=rip_markdown&collection-url=entityId%3D26869335-5546d063-156b-4529-915f-909dd628c090%26entityType%3Dcollection%26workspaceId%3D339a4ee7-378b-45c9-b5b8-fd2c0a9c2442) [![Run in Postman](https://run.pstmn.io/button.svg)](https://god.gw.postman.com/run-collection/26869335-5546d063-156b-4529-915f-909dd628c090?action=collection%2Ffork&source=rip_markdown&collection-url=entityId%3D26869335-5546d063-156b-4529-915f-909dd628c090%26entityType%3Dcollection%26workspaceId%3D339a4ee7-378b-45c9-b5b8-fd2c0a9c2442)
version: 1.5.4 version: 1.5.5
contact: contact:
name: DavidsonGomes name: DavidsonGomes
email: contato@agenciadgcode.com email: contato@agenciadgcode.com

View File

@ -61,6 +61,7 @@ export class SendPollDto extends Metadata {
export type MediaType = 'image' | 'document' | 'video' | 'audio'; export type MediaType = 'image' | 'document' | 'video' | 'audio';
export class MediaMessage { export class MediaMessage {
mediatype: MediaType; mediatype: MediaType;
mimetype?: string;
caption?: string; caption?: string;
// for document // for document
fileName?: string; fileName?: string;

View File

@ -1188,7 +1188,6 @@ export class WAStartupService {
const proxyUrls = text.split('\r\n'); const proxyUrls = text.split('\r\n');
const rand = Math.floor(Math.random() * Math.floor(proxyUrls.length)); const rand = Math.floor(Math.random() * Math.floor(proxyUrls.length));
const proxyUrl = 'http://' + proxyUrls[rand]; const proxyUrl = 'http://' + proxyUrls[rand];
console.log(proxyUrl);
options = { options = {
agent: new ProxyAgent(proxyUrl as any), agent: new ProxyAgent(proxyUrl as any),
}; };
@ -2447,11 +2446,15 @@ export class WAStartupService {
let mimetype: string; let mimetype: string;
if (mediaMessage.mimetype) {
mimetype = mediaMessage.mimetype;
} else {
if (isURL(mediaMessage.media)) { if (isURL(mediaMessage.media)) {
mimetype = getMIMEType(mediaMessage.media); mimetype = getMIMEType(mediaMessage.media);
} else { } else {
mimetype = getMIMEType(mediaMessage.fileName); mimetype = getMIMEType(mediaMessage.fileName);
} }
}
this.logger.verbose('Mimetype: ' + mimetype); this.logger.verbose('Mimetype: ' + mimetype);