new(basic.gblib): SEND FILE pdf as temporary images.

This commit is contained in:
me@rodrigorodriguez.com 2024-10-03 20:11:50 -03:00
parent 8590607aa9
commit 2cffae858c
3 changed files with 12 additions and 4 deletions

View file

@ -1462,7 +1462,7 @@ export class DialogKeywords {
const pngs = await GBUtil.pdfPageAsImage(min, pdf, undefined);
await CollectionUtil.asyncForEach(pngs, async png => {
await GBUtil.sleep(500);
await GBUtil.sleep(2000);
// Prepare a cache to be referenced by Bot Framework.
url = urlJoin(GBServer.globals.publicAddress, min.botId, 'cache', path.basename(png.localName));

View file

@ -1114,7 +1114,11 @@ export class GBMinService {
step.context.activity['pid'] = pid;
const notes = min.core.getParam(min.instance, 'Notes', null);
await this.handleUploads(min, step, user, params, notes != null);
if (await this.handleUploads(min, step, user, params, notes != null))
{
return;
}
// Required for MSTEAMS handling of persisted conversations.
@ -1358,7 +1362,7 @@ export class GBMinService {
private async handleUploads(min, step, user, params, autoSave) {
// Prepare Promises to download each attachment and then execute each Promise.
let ret = false;
if (
step.context.activity.attachments &&
step.context.activity.attachments[0] &&
@ -1370,6 +1374,7 @@ export class GBMinService {
const successfulSaves = await Promise.all(promises);
async function replyForReceivedAttachments(attachmentData) {
if (attachmentData) {
// In case of not having HEAR activated before, it is
// a upload with no Dialog, so run Auto Save to .gbdrive.
@ -1406,6 +1411,7 @@ export class GBMinService {
const replyPromises = successfulSaves.map(replyForReceivedAttachments.bind(step.context));
await Promise.all(replyPromises);
if (successfulSaves.length > 0) {
ret = true;
class GBFile {
data: Buffer;
filename: string;
@ -1429,11 +1435,13 @@ export class GBMinService {
throw new Error('It is only possible to upload one file per message, right now.');
}
min.cbMap[user.userId].promise = results[0];
return;
} else {
return;
}
}
}
return ret;
}
/**

View file

@ -802,8 +802,8 @@ export class WhatsappDirectLine extends GBService {
image: {
link: imageUrl,
caption: caption,
view_once: true
},
view_once: true
};
const response = await fetch(sendMessageEndpoint, {