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)) {
|
if (AdminDialog.isIntentYes(locale, step.result)) {
|
||||||
let from = step.context.activity.from.id;
|
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) {
|
if (!canPublish) {
|
||||||
await step.beginDialog('/admin-auth');
|
await step.beginDialog('/admin-auth');
|
||||||
|
@ -311,6 +316,7 @@ export class AdminDialog extends IGBDialog {
|
||||||
* @param phone Phone number to check (eg.: +5521900002233)
|
* @param phone Phone number to check (eg.: +5521900002233)
|
||||||
*/
|
*/
|
||||||
public static canPublish(min: GBMinInstance, phone: string): Boolean {
|
public static canPublish(min: GBMinInstance, phone: string): Boolean {
|
||||||
|
if (process.env.SECURITY_CAN_PUBLISH !== undefined) {
|
||||||
const list = process.env.SECURITY_CAN_PUBLISH.split(';');
|
const list = process.env.SECURITY_CAN_PUBLISH.split(';');
|
||||||
let result = list.includes(phone);
|
let result = list.includes(phone);
|
||||||
|
|
||||||
|
@ -320,6 +326,7 @@ export class AdminDialog extends IGBDialog {
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static setupSecurityDialogs(min: GBMinInstance) {
|
private static setupSecurityDialogs(min: GBMinInstance) {
|
||||||
min.dialogs.add(
|
min.dialogs.add(
|
||||||
|
@ -353,7 +360,7 @@ export class AdminDialog extends IGBDialog {
|
||||||
min.adminService.setValue(min.instance.instanceId, 'AntiCSRFAttackState', state);
|
min.adminService.setValue(min.instance.instanceId, 'AntiCSRFAttackState', state);
|
||||||
|
|
||||||
const url = `https://login.microsoftonline.com/${
|
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(
|
}/oauth2/authorize?client_id=${min.instance.marketplaceId}&response_type=code&redirect_uri=${urlJoin(
|
||||||
min.instance.botEndpoint,
|
min.instance.botEndpoint,
|
||||||
min.instance.botId,
|
min.instance.botId,
|
||||||
|
|
|
@ -376,7 +376,7 @@ export class AzureDeployerService implements IGBInstallationDeployer {
|
||||||
keys = await this.cognitiveClient.accounts.listKeys(name, nlp.name);
|
keys = await this.cognitiveClient.accounts.listKeys(name, nlp.name);
|
||||||
const nlpAppId = await this.createNLPService(name, name, instance.cloudLocation, culture, instance.nlpAuthoringKey);
|
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.nlpKey = keys.key1;
|
||||||
instance.nlpAppId = nlpAppId;
|
instance.nlpAppId = nlpAppId;
|
||||||
|
|
||||||
|
@ -388,7 +388,7 @@ export class AzureDeployerService implements IGBInstallationDeployer {
|
||||||
GBLog.info(`Deploying Bot Storage...`);
|
GBLog.info(`Deploying Bot Storage...`);
|
||||||
const administratorLogin = `sa${GBAdminService.getRndReadableIdentifier()}`;
|
const administratorLogin = `sa${GBAdminService.getRndReadableIdentifier()}`;
|
||||||
const administratorPassword = GBAdminService.getRndPassword();
|
const administratorPassword = GBAdminService.getRndPassword();
|
||||||
const storageServer = `${name.toLowerCase()}-storage-server2`;
|
const storageServer = `${name.toLowerCase()}-storage-server`;
|
||||||
const storageName = `${name}-storage`;
|
const storageName = `${name}-storage`;
|
||||||
await this.createStorageServer(name, storageServer, administratorLogin,
|
await this.createStorageServer(name, storageServer, administratorLogin,
|
||||||
administratorPassword, storageServer, instance.cloudLocation
|
administratorPassword, storageServer, instance.cloudLocation
|
||||||
|
|
|
@ -620,8 +620,10 @@ export class GBMinService {
|
||||||
'web',
|
'web',
|
||||||
member.name
|
member.name
|
||||||
);
|
);
|
||||||
if (step.context.activity.channelId === "msteams"){
|
if (step.context.activity.channelId === 'msteams') {
|
||||||
persistedUser.conversationReference = JSON.stringify(TurnContext.getConversationReference(context.activity));
|
persistedUser.conversationReference = JSON.stringify(
|
||||||
|
TurnContext.getConversationReference(context.activity)
|
||||||
|
);
|
||||||
await persistedUser.save();
|
await persistedUser.save();
|
||||||
}
|
}
|
||||||
const analytics = new AnalyticsService();
|
const analytics = new AnalyticsService();
|
||||||
|
@ -753,14 +755,12 @@ export class GBMinService {
|
||||||
} else if (context.activity.text.startsWith('{"title"')) {
|
} else if (context.activity.text.startsWith('{"title"')) {
|
||||||
await step.beginDialog('/menu', JSON.parse(context.activity.text));
|
await step.beginDialog('/menu', JSON.parse(context.activity.text));
|
||||||
// Otherwise, continue to the active dialog in the stack.
|
// Otherwise, continue to the active dialog in the stack.
|
||||||
} else {
|
} else if (!(await this.deployer.getStoragePackageByName(min.instance.instanceId, `${min.instance.botId}.gbkb`))) {
|
||||||
if (!(await this.deployer.getStoragePackageByName(min.instance.instanceId, `${min.instance.botId}.gbkb`))) {
|
|
||||||
await step.context.sendActivity(
|
await step.context.sendActivity(
|
||||||
`Oi, ainda não possuo pacotes de conhecimento publicados. Por favor, aguarde alguns segundos enquanto eu auto-publico alguns pacotes.`
|
`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 });
|
await step.beginDialog('/publish', { confirm: true, firstTime: true });
|
||||||
}
|
} else {
|
||||||
|
|
||||||
if (step.activeDialog !== undefined) {
|
if (step.activeDialog !== undefined) {
|
||||||
await step.continueDialog();
|
await step.continueDialog();
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Reference in a new issue