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

This commit is contained in:
Rodrigo Rodriguez (Pragmatismo) 2025-04-19 14:20:15 -03:00
parent 47e3c7648b
commit 7c05a95054

View file

@ -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);