Skip to content

Commit

Permalink
fix: add skillConfiguration settings for old bot (#4724)
Browse files Browse the repository at this point in the history
* fix: add skillConfiguration settings for old bot

* add update file for get

Co-authored-by: Dong Lei <donglei@microsoft.com>
  • Loading branch information
lei9444 and boydc2014 committed Nov 9, 2020
1 parent dccdb1c commit 0ce4990
Showing 1 changed file with 17 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import set from 'lodash/set';
import { DialogSetting, SensitiveProperties } from '@bfc/shared';
import { UserIdentity } from '@bfc/extension';
import has from 'lodash/has';
import get from 'lodash/get';
import set from 'lodash/set';

import { Path } from '../../utility/path';
import log from '../../logger';

import { FileSettingManager } from './fileSettingManager';
const debug = log.extend('default-settings-manager');

const newSettingsValuePath = ['downsampling', 'luis.endpoint', 'luis.authoringEndpoint', 'skillConfiguration'];

export class DefaultSettingManager extends FileSettingManager {
constructor(basePath: string, user?: UserIdentity) {
super(basePath, user);
Expand Down Expand Up @@ -90,18 +94,19 @@ export class DefaultSettingManager extends FileSettingManager {

public async get(obfuscate = false): Promise<any> {
const result = await super.get(obfuscate);
//add downsampling property for old bot
if (!result.downsampling) {
result.downsampling = this.createDefaultSettings().downsampling;
}
//add luis endpoint for old bot
if (!result.luis.endpoint && result.luis.endpoint !== '') {
result.luis.endpoint = this.createDefaultSettings().luis.endpoint;
}
//add luis authoring endpoint for old bot
if (!result.luis.authoringEndpoint && result.luis.authoringEndpoint !== '') {
result.luis.authoringEndpoint = this.createDefaultSettings().luis.authoringEndpoint;
const defaultValue = this.createDefaultSettings();
let updateFile = false;
newSettingsValuePath.forEach((jsonPath: string) => {
if (!has(result, jsonPath)) {
set(result, jsonPath, get(defaultValue, jsonPath));
updateFile = true;
}
});

if (updateFile) {
this.set(result);
}

return result;
}

Expand Down

0 comments on commit 0ce4990

Please sign in to comment.