Skip to content

Commit

Permalink
fix(core.gbapp): New key word SEND FILE TO added.
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigorodriguez committed Nov 11, 2020
1 parent f712d31 commit b736f04
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
12 changes: 10 additions & 2 deletions packages/core.gbapp/services/GBAPIService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -537,12 +537,20 @@ export class DialogClass {

// 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) {
return await this.internalSendFile(step, null, filename, caption);
}

private async internalSendFile(step, mobile, filename, caption) {
if (filename.indexOf('.md') > -1) {
GBLog.info(`BASIC: Sending the contents of ${filename} markdown to mobile.`);
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 {
GBLog.info(`BASIC: Sending the file ${filename} to mobile.`);
let url = urlJoin(
Expand All @@ -554,7 +562,7 @@ export class DialogClass {
filename
);

await this.min.conversationalService.sendFile(this.min, step, null, url, caption);
await this.min.conversationalService.sendFile(this.min, step, mobile, url, caption);
}
}

Expand Down
3 changes: 3 additions & 0 deletions packages/core.gbapp/services/GBVMService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,9 @@ export class GBVMService extends GBService {
code = code.replace(/(send file)(\s*)(.*)/gi, ($0, $1, $2, $3) => {
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) => {
return `sys().save(${$3})\n`;
Expand Down
2 changes: 0 additions & 2 deletions packages/kb.gbapp/services/KBService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -631,8 +631,6 @@ export class KBService implements IGBKBService {
where: { instanceId: instance.instanceId, packageId: packageId }
});
await this.undeployPackageFromStorage(instance, packageId);

GBLog.info('Remember to call rebuild index manually after package removal.');
}

private async undeployPackageFromStorage(instance: any, packageId: number) {
Expand Down

0 comments on commit b736f04

Please sign in to comment.