fix(core.gbapp): Auto-publish fixed.
This commit is contained in:
parent
532fd5139f
commit
398b95d148
3 changed files with 27 additions and 20 deletions
|
@ -229,7 +229,12 @@ export class AdminDialog extends IGBDialog {
|
|||
if (AdminDialog.isIntentYes(locale, step.result)) {
|
||||
let from = step.context.activity.from.id;
|
||||
|
||||
let canPublish = AdminDialog.canPublish(min, from);
|
||||
let canPublish: Boolean;
|
||||
if (step.activeDialog.state.options.firstTime) {
|
||||
canPublish = true;
|
||||
} else {
|
||||
canPublish = AdminDialog.canPublish(min, from);
|
||||
}
|
||||
|
||||
if (!canPublish) {
|
||||
await step.beginDialog('/admin-auth');
|
||||
|
@ -277,7 +282,7 @@ export class AdminDialog extends IGBDialog {
|
|||
if (packageName.indexOf('.') !== -1) {
|
||||
cmd1 = `deployPackage ${process.env.STORAGE_SITE} /${process.env.STORAGE_LIBRARY}/${botId}.gbai/${packageName}`;
|
||||
} else {
|
||||
cmd1 = `deployPackage ${packageName}`;
|
||||
cmd1 = `deployPackage ${packageName}`;
|
||||
}
|
||||
if ((await (deployer as any).getStoragePackageByName(min.instance.instanceId, packageName)) !== null) {
|
||||
const cmd2 = `undeployPackage ${packageName}`;
|
||||
|
@ -311,14 +316,16 @@ export class AdminDialog extends IGBDialog {
|
|||
* @param phone Phone number to check (eg.: +5521900002233)
|
||||
*/
|
||||
public static canPublish(min: GBMinInstance, phone: string): Boolean {
|
||||
const list = process.env.SECURITY_CAN_PUBLISH.split(';');
|
||||
let result = list.includes(phone);
|
||||
if (process.env.SECURITY_CAN_PUBLISH !== undefined) {
|
||||
const list = process.env.SECURITY_CAN_PUBLISH.split(';');
|
||||
let result = list.includes(phone);
|
||||
|
||||
if (!result && min.instance.params) {
|
||||
const params = JSON.parse(min.instance.params);
|
||||
return list.includes(params['Can Publish']);
|
||||
if (!result && min.instance.params) {
|
||||
const params = JSON.parse(min.instance.params);
|
||||
return list.includes(params['Can Publish']);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private static setupSecurityDialogs(min: GBMinInstance) {
|
||||
|
@ -353,7 +360,7 @@ export class AdminDialog extends IGBDialog {
|
|||
min.adminService.setValue(min.instance.instanceId, 'AntiCSRFAttackState', state);
|
||||
|
||||
const url = `https://login.microsoftonline.com/${
|
||||
min.instance.authenticatorTenant
|
||||
step.activeDialog.state.authenticatorTenant
|
||||
}/oauth2/authorize?client_id=${min.instance.marketplaceId}&response_type=code&redirect_uri=${urlJoin(
|
||||
min.instance.botEndpoint,
|
||||
min.instance.botId,
|
||||
|
|
|
@ -376,7 +376,7 @@ export class AzureDeployerService implements IGBInstallationDeployer {
|
|||
keys = await this.cognitiveClient.accounts.listKeys(name, nlp.name);
|
||||
const nlpAppId = await this.createNLPService(name, name, instance.cloudLocation, culture, instance.nlpAuthoringKey);
|
||||
|
||||
instance.nlpEndpoint = urlJoin(nlp.endpoint, 'apps');
|
||||
instance.nlpEndpoint = nlp.endpoint;
|
||||
instance.nlpKey = keys.key1;
|
||||
instance.nlpAppId = nlpAppId;
|
||||
|
||||
|
@ -388,7 +388,7 @@ export class AzureDeployerService implements IGBInstallationDeployer {
|
|||
GBLog.info(`Deploying Bot Storage...`);
|
||||
const administratorLogin = `sa${GBAdminService.getRndReadableIdentifier()}`;
|
||||
const administratorPassword = GBAdminService.getRndPassword();
|
||||
const storageServer = `${name.toLowerCase()}-storage-server2`;
|
||||
const storageServer = `${name.toLowerCase()}-storage-server`;
|
||||
const storageName = `${name}-storage`;
|
||||
await this.createStorageServer(name, storageServer, administratorLogin,
|
||||
administratorPassword, storageServer, instance.cloudLocation
|
||||
|
|
|
@ -620,8 +620,10 @@ export class GBMinService {
|
|||
'web',
|
||||
member.name
|
||||
);
|
||||
if (step.context.activity.channelId === "msteams"){
|
||||
persistedUser.conversationReference = JSON.stringify(TurnContext.getConversationReference(context.activity));
|
||||
if (step.context.activity.channelId === 'msteams') {
|
||||
persistedUser.conversationReference = JSON.stringify(
|
||||
TurnContext.getConversationReference(context.activity)
|
||||
);
|
||||
await persistedUser.save();
|
||||
}
|
||||
const analytics = new AnalyticsService();
|
||||
|
@ -753,14 +755,12 @@ export class GBMinService {
|
|||
} else if (context.activity.text.startsWith('{"title"')) {
|
||||
await step.beginDialog('/menu', JSON.parse(context.activity.text));
|
||||
// Otherwise, continue to the active dialog in the stack.
|
||||
} else if (!(await this.deployer.getStoragePackageByName(min.instance.instanceId, `${min.instance.botId}.gbkb`))) {
|
||||
await step.context.sendActivity(
|
||||
`Oi, ainda não possuo pacotes de conhecimento publicados. Por favor, aguarde alguns segundos enquanto eu auto-publico alguns pacotes.`
|
||||
);
|
||||
await step.beginDialog('/publish', { confirm: true, firstTime: true });
|
||||
} else {
|
||||
if (!(await this.deployer.getStoragePackageByName(min.instance.instanceId, `${min.instance.botId}.gbkb`))) {
|
||||
await step.context.sendActivity(
|
||||
`Oi, ainda não possuo pacotes de conhecimento publicados. Por favor, aguarde alguns segundos enquanto eu auto-publico alguns pacotes.`
|
||||
);
|
||||
return await step.beginDialog('/publish', { confirm: true });
|
||||
}
|
||||
|
||||
if (step.activeDialog !== undefined) {
|
||||
await step.continueDialog();
|
||||
} else {
|
||||
|
|
Loading…
Add table
Reference in a new issue