fix(basic.gblib): Refactoring processInfo into all methods.

This commit is contained in:
Daniel Lima 2023-01-17 11:03:25 -03:00
parent 5166db205e
commit 50d3fccd0d
2 changed files with 38 additions and 22 deletions

View file

@ -1035,15 +1035,31 @@ export class DialogKeywords {
} }
} }
public async getProcessInfo(pid: number) {
const proc = GBServer.globals.processes[pid];
const min = GBServer.globals.minInstances.filter(p =>
p.instance.instanceId == proc.instanceId)[0];
const sec = new SecService();
const user = await sec.getUserFromId(min.instance.instanceId, proc.userId);
return {
min, user
}
}
/** /**
* Talks to the user by using the specified text. * Talks to the user by using the specified text.
*/ */
public async talk({ pid, text }) { public async talk({ pid, text }) {
GBLog.info(`BASIC: TALK '${text}'.`); GBLog.info(`BASIC: TALK '${text}'.`);
if (this.user) { const {
const translate = this.user ? this.user.basicOptions.translatorOn : false; min, user
} = await this.getProcessInfo(pid);
if (user) {
// TODO: const translate = this.user ? this.user.basicOptions.translatorOn : false;
await this.min.conversationalService['sendOnConversation'](this.min, this.user.systemUser, text); await min.conversationalService['sendOnConversation'](min, user, text);
} }
} }

View file

@ -104,11 +104,11 @@ export class GBDeployer implements IGBDeployer {
* Retrives token and initialize drive client API. * Retrives token and initialize drive client API.
*/ */
public static async internalGetDriveClient (min: GBMinInstance) { public static async internalGetDriveClient (min: GBMinInstance) {
let token = await min.adminService.acquireElevatedToken(min.instance.instanceId); const token = await min.adminService.acquireElevatedToken(min.instance.instanceId);
let siteId = process.env.STORAGE_SITE_ID; const siteId = process.env.STORAGE_SITE_ID;
let libraryId = process.env.STORAGE_LIBRARY; const libraryId = process.env.STORAGE_LIBRARY;
let client = MicrosoftGraph.Client.init({ const client = MicrosoftGraph.Client.init({
authProvider: done => { authProvider: done => {
done(null, token); done(null, token);
} }