fix(basic.gblib): Goto dialog within web.

This commit is contained in:
Rodrigo Rodriguez 2021-09-18 09:41:18 -03:00
parent 7c446699eb
commit 565f200ebf
2 changed files with 13 additions and 9 deletions

View file

@ -453,18 +453,22 @@ export class DialogKeywords {
/** /**
* Prepares the next dialog to be shown to the specified user. * Prepares the next dialog to be shown to the specified user.
*/ */
public async gotoDialog(step, fromOrDialogName: string, dialogName: string) { public async gotoDialog(step, fromOrDialogName: string, dialogName: string) {
if (dialogName) { if (dialogName) {
let sec = new SecService(); if (dialogName.charAt(0) === '/') {
let user = await sec.getUserFromSystemId(fromOrDialogName); await step.beginDialog(fromOrDialogName);
if (!user) { } else {
user = await sec.ensureUser(this.min.instance.instanceId, fromOrDialogName, let sec = new SecService();
fromOrDialogName, null, 'whatsapp', 'from', null); let user = await sec.getUserFromSystemId(fromOrDialogName);
if (!user) {
user = await sec.ensureUser(this.min.instance.instanceId, fromOrDialogName,
fromOrDialogName, null, 'whatsapp', 'from', null);
}
await sec.updateUserHearOnDialog(user.userId, dialogName);
} }
await sec.updateUserHearOnDialog(user.userId, dialogName);
} }
else { else {
await step.beginDialog(dialogName); await step.beginDialog(fromOrDialogName);
} }
} }

View file

@ -242,7 +242,7 @@ export class GBVMService extends GBService {
}); });
code = code.replace(/(go to)(\s)(.*)/gi, ($0, $1, $2, $3) => { code = code.replace(/(go to)(\s)(.*)/gi, ($0, $1, $2, $3) => {
return `sys().gotoDialog(step, ${$3})\n`; return `gotoDialog(step, ${$3})\n`;
}); });
code = code.replace(/(hear)\s*(\w+)/gi, ($0, $1, $2) => { code = code.replace(/(hear)\s*(\w+)/gi, ($0, $1, $2) => {