Skip to content

Commit

Permalink
fix mimetype
Browse files Browse the repository at this point in the history
  • Loading branch information
clairton committed Apr 10, 2023
1 parent ab74a97 commit f6afbac
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion __tests__/services/transformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,7 @@ describe('service transformer', () => {
}
const output = {
caption: body,
mimeType: mimetype,
mimetype,
video: {
url: link,
},
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
4 changes: 2 additions & 2 deletions src/services/transformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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] = {
Expand Down

0 comments on commit f6afbac

Please sign in to comment.