Skip to content

Commit

Permalink
fix(core.gbapp): Trying to fix Config.xlsx access from customer.
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigorodriguez committed Jan 8, 2021
1 parent d38c629 commit c2a51ff
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions packages/core.gbapp/services/GBDeployer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -367,22 +367,27 @@ export class GBDeployer implements IGBDeployer {
* Loads all para from tabular file Config.xlsx.
*/
public async loadParamsFromTabular(min: GBMinInstance): Promise<any> {
const siteId = process.env.STORAGE_SITE_ID;
const libraryId = process.env.STORAGE_LIBRARY;

GBLog.info(`Connecting to Config.xslx (siteId: ${siteId}, libraryId: ${libraryId})...`);

// Connects to MSFT storage.

const token = await min.adminService.acquireElevatedToken(min.instance.instanceId);
const siteId = process.env.STORAGE_SITE_ID;
const libraryId = process.env.STORAGE_LIBRARY;
const client = MicrosoftGraph.Client.init({
authProvider: done => {
done(null, token);
}
});



// Retrives all files in .bot folder.

const botId = min.instance.botId;
const path = `/${botId}.gbai/${botId}.gbot`;
GBLog.info(`Loading .gbot from ${path}.`);

const res = await client
.api(`https://graph.microsoft.com/v1.0/sites/${siteId}/lists/${libraryId}/drive/root:${path}:/children`)
.get();
Expand Down Expand Up @@ -491,24 +496,25 @@ export class GBDeployer implements IGBDeployer {
if (handled) {
return pck;
}

// Deploy platform packages here accordingly to their extension.

switch (packageType) {
case '.gbot':

// Extracts configuration information from .gbot files.

if (process.env.ENABLE_PARAMS_ONLINE === 'false') {
if (Fs.existsSync(localPath)) {
GBLog.info(`Loading .gbot from ${localPath}.`);
await this.deployBotFromLocalPath(localPath, GBServer.globals.publicAddress);
}
} else {
min.instance.params = await this.loadParamsFromTabular(min);
}

// Updates instance object.

await this.core.saveInstance(min.instance);

break;
Expand Down

0 comments on commit c2a51ff

Please sign in to comment.