fix(DialogKeywords): update file writing method and adjust WhatsApp file sending logic
All checks were successful
GBCI / build (push) Successful in 28s
All checks were successful
GBCI / build (push) Successful in 28s
This commit is contained in:
parent
47e3c7648b
commit
7c05a95054
1 changed files with 8 additions and 2 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Reference in a new issue