Skip to content

Commit

Permalink
new(basic.gblib): SEND FILE pdf as temporary images.
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigorodriguez committed Oct 3, 2024
1 parent 8590607 commit 2cffae8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/basic.gblib/services/DialogKeywords.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
12 changes: 10 additions & 2 deletions packages/core.gbapp/services/GBMinService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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] &&
Expand All @@ -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.

Expand Down Expand Up @@ -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;
Expand All @@ -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;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/whatsapp.gblib/services/WhatsappDirectLine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand Down

0 comments on commit 2cffae8

Please sign in to comment.