mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-23 04:22:02 -06:00
fix: when receiving a file from whatsapp, use the original filename in chatwoot when possible
This commit is contained in:
parent
dfc8330035
commit
7430897085
@ -1561,8 +1561,15 @@ export class ChatwootService {
|
||||
},
|
||||
});
|
||||
|
||||
const random = Math.random().toString(36).substring(7);
|
||||
const nameFile = `${random}.${mimeTypes.extension(downloadBase64.mimetype)}`;
|
||||
let prependFilename: string;
|
||||
if (body?.message[body?.messageType]?.fileName) {
|
||||
prependFilename = `${path.parse(body.message[body.messageType].fileName).name}-${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');
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user