fix(core.gbapp): New key word SEND FILE TO added.

This commit is contained in:
Rodrigo Rodriguez 2020-11-11 11:10:40 -03:00
parent f712d31866
commit b736f04103
3 changed files with 13 additions and 4 deletions

View file

@ -538,11 +538,19 @@ export class DialogClass {
// TODO: Choose Fuse with country code or consent IP. // TODO: Choose Fuse with country code or consent IP.
} }
public async sendFileTo(step, mobile, filename, caption) {
return await this.internalSendFile(null, mobile, filename, caption);
}
public async sendFile(step, filename, caption) { public async sendFile(step, filename, caption) {
return await this.internalSendFile(step, null, filename, caption);
}
private async internalSendFile(step, mobile, filename, caption) {
if (filename.indexOf('.md') > -1) { if (filename.indexOf('.md') > -1) {
GBLog.info(`BASIC: Sending the contents of ${filename} markdown to mobile.`); GBLog.info(`BASIC: Sending the contents of ${filename} markdown to mobile.`);
let md = await this.min.kbService.getAnswerTextByMediaName(this.min.instance.instanceId, filename); let md = await this.min.kbService.getAnswerTextByMediaName(this.min.instance.instanceId, filename);
await this.min.conversationalService.sendMarkdownToMobile(this.min, step, null, md); await this.min.conversationalService.sendMarkdownToMobile(this.min, step, mobile, md);
} else { } else {
GBLog.info(`BASIC: Sending the file ${filename} to mobile.`); GBLog.info(`BASIC: Sending the file ${filename} to mobile.`);
let url = urlJoin( let url = urlJoin(
@ -554,7 +562,7 @@ export class DialogClass {
filename filename
); );
await this.min.conversationalService.sendFile(this.min, step, null, url, caption); await this.min.conversationalService.sendFile(this.min, step, mobile, url, caption);
} }
} }

View file

@ -219,6 +219,9 @@ export class GBVMService extends GBService {
code = code.replace(/(send file)(\s*)(.*)/gi, ($0, $1, $2, $3) => { code = code.replace(/(send file)(\s*)(.*)/gi, ($0, $1, $2, $3) => {
return `sendFile (step, ${$3})\n`; return `sendFile (step, ${$3})\n`;
}); });
code = code.replace(/(send file to)(\s*)(.*)/gi, ($0, $1, $2, $3) => {
return `sendFileTo (step, ${$3})\n`;
});
code = code.replace(/(save)(\s)(.*)/gi, ($0, $1, $2, $3) => { code = code.replace(/(save)(\s)(.*)/gi, ($0, $1, $2, $3) => {
return `sys().save(${$3})\n`; return `sys().save(${$3})\n`;

View file

@ -631,8 +631,6 @@ export class KBService implements IGBKBService {
where: { instanceId: instance.instanceId, packageId: packageId } where: { instanceId: instance.instanceId, packageId: packageId }
}); });
await this.undeployPackageFromStorage(instance, packageId); await this.undeployPackageFromStorage(instance, packageId);
GBLog.info('Remember to call rebuild index manually after package removal.');
} }
private async undeployPackageFromStorage(instance: any, packageId: number) { private async undeployPackageFromStorage(instance: any, packageId: number) {