From 7c05a9505409d412cddc1cdab79d66e0161de843 Mon Sep 17 00:00:00 2001 From: "Rodrigo Rodriguez (Pragmatismo)" Date: Sat, 19 Apr 2025 14:20:15 -0300 Subject: [PATCH] fix(DialogKeywords): update file writing method and adjust WhatsApp file sending logic --- packages/basic.gblib/services/DialogKeywords.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/basic.gblib/services/DialogKeywords.ts b/packages/basic.gblib/services/DialogKeywords.ts index 273e8cd6..d1d97d0b 100644 --- a/packages/basic.gblib/services/DialogKeywords.ts +++ b/packages/basic.gblib/services/DialogKeywords.ts @@ -1565,7 +1565,7 @@ export class DialogKeywords { } if (localName.endsWith('.image.pdf')) { - + GBLogEx.info(min, `Converting PDF to images...`); const pngs = await GBUtil.pdfPageAsImage(min, localName, undefined); await CollectionUtil.asyncForEach(pngs, async png => { @@ -1583,6 +1583,9 @@ export class DialogKeywords { contentUrl: url }); + + + if (!isNaN(mobile)) { await min.whatsAppDirectLine.sendFileToDevice(mobile, url, filename, caption, undefined, true); } else { @@ -1603,8 +1606,11 @@ export class DialogKeywords { const buf = await fs.readFile(filename); const gbaiName = GBUtil.getGBAIPath(min.botId); const localName = path.join('work', gbaiName, 'cache', `tmp${GBAdminService.getRndReadableIdentifier()}.${ext}`); - await fs.writeFile(localName, buf, { encoding: null }); url = urlJoin(GBServer.globals.publicAddress, min.botId, 'cache', path.basename(localName)); + + GBLogEx.info(min, `Exposing ${localName} to ${url}...`); + + await fs.writeFile(localName, new Uint8Array(buf), { encoding: null }); } const contentType = mime.lookup(url);