fix(basic.gblib): Fix BASIC options set by SET instructions.

This commit is contained in:
Rodrigo Rodriguez 2021-04-30 13:20:49 -03:00
parent 53a5d8d692
commit 80697cf944
2 changed files with 18 additions and 10 deletions

View file

@ -57,8 +57,11 @@ export class DialogKeywords {
* Reference to the base system keywords functions to be called.
*/
public internalSys: SystemKeywords;
private user;
/**
* Current user object to get BASIC properties read.
*/
public user;
/**
* When creating this keyword facade, a bot instance is
@ -66,8 +69,8 @@ export class DialogKeywords {
*/
constructor(min: GBMinInstance, deployer: GBDeployer, step: GBDialogStep, user) {
this.min = min;
this.internalSys = new SystemKeywords(min, deployer, user);
this.user = user;
this.internalSys = new SystemKeywords(min, deployer, this);
}
/**
@ -163,6 +166,7 @@ export class DialogKeywords {
user.systemUser = await sec.updateUserLocale(user.systemUser.userId, language);
await this.min.userProfile.set(step.context, user);
this.user = user;
}
/**
@ -175,8 +179,9 @@ export class DialogKeywords {
const user = await this.min.userProfile.get(step.context, {});
user.basicOptions.maxLines = count;
await this.min.userProfile.set(step.context, user);
this.user = user;
}
/**
* Defines translator behaviour.
*
@ -187,6 +192,7 @@ export class DialogKeywords {
const user = await this.min.userProfile.get(step.context, {});
user.basicOptions.translatorOn = (on.trim() === "on");
await this.min.userProfile.set(step.context, user);
this.user = user;
}
/**

View file

@ -37,6 +37,7 @@ import urlJoin = require('url-join');
import { GBAdminService } from '../../admin.gbapp/services/GBAdminService';
import { GBDeployer } from '../../core.gbapp/services/GBDeployer';
import { SecService } from '../../security.gbapp/services/SecService';
import { DialogKeywords } from './DialogKeywords';
const request = require('request-promise-native');
const path = require('path');
const sgMail = require('@sendgrid/mail');
@ -59,17 +60,18 @@ export class SystemKeywords {
* Reference to the deployer service.
*/
private readonly deployer: GBDeployer;
dk: DialogKeywords;
private user;
/**
* When creating this keyword facade, a bot instance is
* specified among the deployer service.
*/
constructor(min: GBMinInstance, deployer: GBDeployer, user) {
this.user = user;
constructor(min: GBMinInstance, deployer: GBDeployer, dk: DialogKeywords) {
this.min = min;
this.deployer = deployer;
this.dk = dk;
}
/**
@ -290,9 +292,9 @@ export class SystemKeywords {
let maxLines = 100;
if (this.user.basicOptions && this.user.basicOptions.maxLines) {
if (this.user.basicOptions.maxLines.toString().toLowerCase() !== "default") {
maxLines = Number.parseInt(this.user.basicOptions.maxLines).valueOf();
if (this.dk.user.basicOptions && this.dk.user.basicOptions.maxLines) {
if (this.dk.user.basicOptions.maxLines.toString().toLowerCase() !== "default") {
maxLines = Number.parseInt(this.dk.user.basicOptions.maxLines).valueOf();
}
}