new(admin.gbapp): Publish command will publish every package type.

This commit is contained in:
Rodrigo Rodriguez 2020-06-14 18:06:29 -03:00
parent 557fcb0931
commit 5a99ef09aa
4 changed files with 60 additions and 45 deletions

View file

@ -232,18 +232,22 @@ export class AdminDialog extends IGBDialog {
step.activeDialog.state.options.args.split(' ')[0] : null; step.activeDialog.state.options.args.split(' ')[0] : null;
const packages = []; const packages = [];
let skipError = false;
if (filename === null || filename === "") { if (filename === null || filename === "") {
await min.conversationalService.sendText(min, step, `Starting publishing for ${botId}.gbkb...`); await min.conversationalService.sendText(min, step, `Starting publishing for ${botId} packages...`);
packages.push(`${botId}.gbkb`); packages.push(`${botId}.gbkb`);
packages.push(`${botId}.gbtheme`);
packages.push(`${botId}.gbdialog`);
packages.push(`${botId}.gbot`);
skipError = true;
} else { } else {
await min.conversationalService.sendText(min, step, `Starting publishing for ${filename}...`); await min.conversationalService.sendText(min, step, `Starting publishing for ${filename}...`);
packages.push(filename); packages.push(filename);
} }
try {
await CollectionUtil.asyncForEach(packages, async packageName => { await CollectionUtil.asyncForEach(packages, async packageName => {
try {
const cmd1 = `deployPackage ${process.env.STORAGE_SITE} /${process.env.STORAGE_LIBRARY}/${botId}.gbai/${packageName}`; const cmd1 = `deployPackage ${process.env.STORAGE_SITE} /${process.env.STORAGE_LIBRARY}/${botId}.gbai/${packageName}`;
if (await (deployer as any).getStoragePackageByName(min.instance.instanceId, if (await (deployer as any).getStoragePackageByName(min.instance.instanceId,
@ -253,12 +257,16 @@ export class AdminDialog extends IGBDialog {
} }
await GBAdminService.deployPackageCommand(min, cmd1, deployer); await GBAdminService.deployPackageCommand(min, cmd1, deployer);
await min.conversationalService.sendText(min, step, `Finished publishing ${packageName}.`); await min.conversationalService.sendText(min, step, `Finished publishing ${packageName}.`);
});
} catch (error) { } catch (error) {
await min.conversationalService.sendText(min, step, `ERROR: ${error}`);
GBLog.error(error); GBLog.error(error);
if (!skipError) {
await min.conversationalService.sendText(min, step, `ERROR: ${error}`);
return await step.replaceDialog('/ask', { isReturning: true }); return await step.replaceDialog('/ask', { isReturning: true });
} }
}
});
await min.conversationalService.sendText(min, step, Messages[locale].publish_success); await min.conversationalService.sendText(min, step, Messages[locale].publish_success);
if (!step.activeDialog.state.options.confirm) { if (!step.activeDialog.state.options.confirm) {
return await step.replaceDialog('/ask', { isReturning: true }); return await step.replaceDialog('/ask', { isReturning: true });

View file

@ -81,6 +81,7 @@ export class WelcomeDialog extends IGBDialog {
: Messages[locale].good_night; : Messages[locale].good_night;
await min.conversationalService.sendText(min, step, Messages[locale].hi(msg)); await min.conversationalService.sendText(min, step, Messages[locale].hi(msg));
await step.replaceDialog('/ask', { firstTime: true }); await step.replaceDialog('/ask', { firstTime: true });
if ( if (

View file

@ -666,6 +666,7 @@ export class GBMinService {
const simpleLocale = context.activity.locale.substring(0, 2); const simpleLocale = context.activity.locale.substring(0, 2);
const hasBadWord = wash.check(simpleLocale, context.activity.text); const hasBadWord = wash.check(simpleLocale, context.activity.text);
if (hasBadWord) { if (hasBadWord) {
await step.beginDialog('/pleaseNoBadWords'); await step.beginDialog('/pleaseNoBadWords');
} else if (isVMCall) { } else if (isVMCall) {
@ -693,6 +694,12 @@ export class GBMinService {
await step.continueDialog(); await step.continueDialog();
} else { } 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 });
}
else {
let query = context.activity.text; let query = context.activity.text;
const translatorEnabled = () => { const translatorEnabled = () => {
@ -733,6 +740,7 @@ export class GBMinService {
} }
} }
} }
}
public static async callVM(text: string, min: GBMinInstance, step: GBDialogStep) { public static async callVM(text: string, min: GBMinInstance, step: GBDialogStep) {
const mainMethod = text.toLowerCase(); const mainMethod = text.toLowerCase();

View file

@ -150,8 +150,6 @@ export class WhatsappDirectLine extends GBService {
} }
public async received(req, res) { public async received(req, res) {
if (req.body.messages === undefined) { if (req.body.messages === undefined) {
res.end(); res.end();
return; // Exit here. return; // Exit here.