fix(DialogKeywords): update file writing method and adjust WhatsApp file sending logic
All checks were successful
GBCI / build (push) Successful in 35s

This commit is contained in:
Rodrigo Rodriguez (Pragmatismo) 2025-04-19 14:13:53 -03:00
parent d55a16aa80
commit 47e3c7648b

View file

@ -1521,7 +1521,7 @@ export class DialogKeywords {
'cache', 'cache',
`${fileOnly.replace(/\s/gi, '')}-${GBAdminService.getNumberIdentifier()}.${ext}` `${fileOnly.replace(/\s/gi, '')}-${GBAdminService.getNumberIdentifier()}.${ext}`
); );
await fs.writeFile(localName, buf, { encoding: null }); await fs.writeFile(localName, new Uint8Array(buf), { encoding: null });
url = urlJoin(GBServer.globals.publicAddress, min.botId, 'cache', path.basename(localName)); url = urlJoin(GBServer.globals.publicAddress, min.botId, 'cache', path.basename(localName));
} else if (GBConfigService.get('GB_MODE') === 'gbcluster') { } else if (GBConfigService.get('GB_MODE') === 'gbcluster') {
@ -1616,8 +1616,8 @@ export class DialogKeywords {
contentUrl: url contentUrl: url
}); });
if (channel === 'omnichannel' || !user) { if (!isNaN(mobile)) {
await min.conversationalService.sendFile(min, null, mobile, url, caption); await min.whatsAppDirectLine.sendFileToDevice(mobile, url, filename, caption, undefined, true);
} else { } else {
await min.conversationalService['sendOnConversation'](min, user, reply); await min.conversationalService['sendOnConversation'](min, user, reply);
} }