diff --git a/__tests__/services/transformer.ts b/__tests__/services/transformer.ts index e56f4b08..22ef37ee 100644 --- a/__tests__/services/transformer.ts +++ b/__tests__/services/transformer.ts @@ -817,7 +817,7 @@ describe('service transformer', () => { } const output = { caption: body, - mimeType: mimetype, + mimetype, video: { url: link, }, diff --git a/package.json b/package.json index 34af22f7..a9a0e939 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "unoapi-cloud", - "version": "0.17.1", + "version": "0.17.3", "description": "Unoapi Cloud", "main": "./dist/index.js", "types": "./dist/index.d.ts", diff --git a/src/services/transformer.ts b/src/services/transformer.ts index 59d730f7..509e98f5 100644 --- a/src/services/transformer.ts +++ b/src/services/transformer.ts @@ -64,7 +64,7 @@ export const toBaileysMessageContent = (payload: any): AnyMessageContent => { case 'video': const url = payload[type].link response.caption = payload[type].caption - response.mimeType = mime.lookup(url) + response.mimetype = mime.lookup(url) if (payload[type].filename) { response.fileName = payload[type].filename } @@ -236,7 +236,7 @@ export const fromBaileysMessageContent = (phone: string, payload: any): any => { case 'documentMessage': const mediaType = messageType.replace('Message', '') const mediaKey = `${phone}/${whatsappMessageId}` - const mimetype = binMessage.mimetype.split(';')[0] + const mimetype = (binMessage.fileName && mime.lookup(binMessage.fileName)) || binMessage.mimetype.split(';')[0] const extension = mime.extension(mimetype) const filename = binMessage.fileName || `${payload.key.id}.${extension}` message[mediaType] = {