fix(basic.gblib): Fix in SEND FILE version.

This commit is contained in:
Rodrigo Rodriguez 2023-11-27 14:40:08 -03:00
parent 66ea211dd5
commit 3f266f1262
3 changed files with 15 additions and 18 deletions

View file

@ -1278,13 +1278,21 @@ export class DialogKeywords {
// .gbdrive direct sending.
else {
const ext = mime.extension(Path.extname(filename.localName));
const buf = Fs.readFileSync(filename);
const ext = mime.extension(Path.extname(filename));
const gbaiName = DialogKeywords.getGBAIPath(min.botId);
const localName = Path.join('work', gbaiName, 'cache', `tmp${GBAdminService.getRndReadableIdentifier()}.${ext}`);
Fs.writeFileSync(localName, buf, { encoding: null });
url = urlJoin(GBServer.globals.publicAddress, min.botId, 'cache', Path.basename(localName));
let { baseUrl, client } = await GBDeployer.internalGetDriveClient(min);
let path = '/' + urlJoin(gbaiName, `${min.botId}.gbdrive`);
const sys = new SystemKeywords();
let template = await sys.internalGetDocument(client, baseUrl, path, filename);
let url = template['@microsoft.graph.downloadUrl'];
const res = await fetch(url);
let buf: any = Buffer.from(await res.arrayBuffer());
let localName1 = Path.join('work', gbaiName, 'cache', `tmp${GBAdminService.getRndReadableIdentifier()}.docx`);
Fs.writeFileSync(localName1, buf, { encoding: null });
url = urlJoin(GBServer.globals.publicAddress, min.botId, 'cache', Path.basename(localName1));
}

View file

@ -1087,17 +1087,6 @@ export class KeywordsExpressions {
$3 = $3.replace(/\"/g, '');
let fields = $3.split(',');
const table = fields[0].trim();
if (table.indexOf('.xlsx') !== -1)
{ // Same as SAVE above.
$3 = $3.replace(/\'/g, '');
$3 = $3.replace(/\"/g, '');
$4 = $4.substr(2);
return `await sys.save({pid: pid, file: "${$3}", args: [${$4}]})`;
}
fields.shift();
const fieldsAsText = fields.join(',');

View file

@ -589,7 +589,7 @@ export class SystemKeywords {
/**
* Retrives a document from the drive, given a path and filename.
*/
private async internalGetDocument(client: any, baseUrl: any, path: string, file: string) {
public async internalGetDocument(client: any, baseUrl: any, path: string, file: string) {
let res = await client.api(`${baseUrl}/drive/root:/${path}:/children`).get();
let documents = res.value.filter(m => {