mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-24 09:28:39 -06:00
Merge pull request #332 from jaison-x/adjust-filename-chatwoot
fix(chatwoot): when receiving a file from whatsapp, use the original filename in chatwoot if possible
This commit is contained in:
commit
5bd3f28117
@ -1527,8 +1527,20 @@ export class ChatwootService {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const random = Math.random().toString(36).substring(7);
|
let prependFilename: string;
|
||||||
const nameFile = `${random}.${mimeTypes.extension(downloadBase64.mimetype)}`;
|
if (
|
||||||
|
body?.message[body?.messageType]?.fileName ||
|
||||||
|
body?.message[body?.messageType]?.message?.documentMessage?.fileName
|
||||||
|
) {
|
||||||
|
prependFilename = path.parse(
|
||||||
|
body?.message[body?.messageType]?.fileName ||
|
||||||
|
body?.message[body?.messageType]?.message?.documentMessage?.fileName,
|
||||||
|
).name;
|
||||||
|
prependFilename += `-${Math.floor(Math.random() * (99 - 10 + 1) + 10)}`;
|
||||||
|
} else {
|
||||||
|
prependFilename = Math.random().toString(36).substring(7);
|
||||||
|
}
|
||||||
|
const nameFile = `${prependFilename}.${mimeTypes.extension(downloadBase64.mimetype)}`;
|
||||||
|
|
||||||
const fileData = Buffer.from(downloadBase64.base64, 'base64');
|
const fileData = Buffer.from(downloadBase64.base64, 'base64');
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user