Skip to content

Commit

Permalink
fix(all): Minor changes in PROD.
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigorodriguez committed Jul 19, 2023
1 parent 182d6c4 commit abe5f03
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 14 deletions.
9 changes: 6 additions & 3 deletions packages/admin.gbapp/services/GBAdminService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,12 @@ export class GBAdminService implements IGBAdminService {
return obj.value;
}

public async acquireElevatedToken(instanceId: number): Promise<string> {
const minBoot = GBServer.globals.minBoot;
instanceId = minBoot.instance.instanceId;
public async acquireElevatedToken(instanceId: number, root: boolean = false): Promise<string> {

if (root){
const minBoot = GBServer.globals.minBoot;
instanceId = minBoot.instance.instanceId;
}
let expiresOnV;
try {
expiresOnV = await this.getValue(instanceId, 'expiresOn');
Expand Down
6 changes: 3 additions & 3 deletions packages/core.gbapp/services/GBDeployer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export class GBDeployer implements IGBDeployer {
* Retrives token and initialize drive client API.
*/
public static async internalGetDriveClient(min: GBMinInstance) {
const token = await min.adminService.acquireElevatedToken(min.instance.instanceId);
const token = await min.adminService['acquireElevatedToken'](min.instance.instanceId, true);
const siteId = process.env.STORAGE_SITE_ID;
const libraryId = process.env.STORAGE_LIBRARY;

Expand Down Expand Up @@ -209,7 +209,7 @@ export class GBDeployer implements IGBDeployer {

// Gets the access token to perform service operations.

const accessToken = await GBServer.globals.minBoot.adminService.acquireElevatedToken(bootInstance.instanceId);
const accessToken = await min.adminService['acquireElevatedToken'](min.instance.instanceId, true);

// Creates the MSFT application that will be associated to the bot.

Expand Down Expand Up @@ -401,7 +401,7 @@ export class GBDeployer implements IGBDeployer {

// Connects to MSFT storage.

const token = await min.adminService.acquireElevatedToken(min.instance.instanceId);
const token = await min.adminService['acquireElevatedToken'](min.instance.instanceId, true);
const client = MicrosoftGraph.Client.init({
authProvider: done => {
done(null, token);
Expand Down
27 changes: 20 additions & 7 deletions packages/core.gbapp/services/GBMinService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,7 @@ export class GBMinService {
min['scheduleMap'] = {};
min['conversationWelcomed'] = {};
min.packages = sysPackages;

// NLP Manager.

const manager = new NlpManager({ languages: ['pt'], forceNER: true });
Expand All @@ -725,7 +725,7 @@ export class GBMinService {
});
}

min.appPackages = await this.core['getApplicationsByInstanceId'] (appPackages, min.instance.instanceId);
min.appPackages = await this.core['getApplicationsByInstanceId'](appPackages, min.instance.instanceId);

// Creates a hub of services available in .gbapps.

Expand Down Expand Up @@ -1050,8 +1050,7 @@ export class GBMinService {
await this.processEventActivity(min, user, context, step);
}
} catch (error) {
const msg = `ERROR: ${error.message} ${error.stack} ${error.error ? error.error.body : ''} ${error.error ? (error.error.stack ? error.error.stack : '') : ''
}`;
const msg = `ERROR: ${error.message} ${error.stack} ${error.error ? error.error.body : ''} ${error.error ? (error.error.stack ? error.error.stack : '') : '' }`;
GBLog.error(msg);

await min.conversationalService.sendText(
Expand All @@ -1065,7 +1064,7 @@ export class GBMinService {
};

try {

await adapter['processActivity'](req, res, handler);
} catch (error) {
if (error.code === 401) {
Expand Down Expand Up @@ -1270,7 +1269,7 @@ export class GBMinService {
accum.push(result);
return accum;
}, []) as GBFile[];

if (min.cbMap[userId] && min.cbMap[userId].promise == '!GBHEAR') {
if (results.length > 1) {
throw new Error('It is only possible to upload one file per message, right now.');
Expand Down Expand Up @@ -1477,7 +1476,21 @@ export class GBMinService {

// If there is a dialog in course, continue to the next step.
else if (step.activeDialog !== undefined) {
await step.continueDialog();

try {
await step.continueDialog();

} catch (error) {
const msg = `ERROR: ${error.message} ${error.stack} ${error.error ? error.error.body : ''} ${error.error ? (error.error.stack ? error.error.stack : '') : '' }`;
GBLog.error(msg);
await min.conversationalService.sendText(
min,
step,
Messages[step.context.activity.locale].very_sorry_about_error
);
await step.beginDialog('/ask', { isReturning: true });
}

} else {
const startDialog = user.hearOnDialog
? user.hearOnDialog
Expand Down
2 changes: 1 addition & 1 deletion packages/security.gbapp/services/SecService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ export class SecService extends GBService {
await CollectionUtil.asyncForEach(list, async item => {
if (
item !== undefined &&
agentSystemId === undefined &&
!agentSystemId &&
item !== userSystemId &&
!(await this.isAgentSystemId(item))
) {
Expand Down

0 comments on commit abe5f03

Please sign in to comment.