fix(core.gbapp): /publish command fixed.
This commit is contained in:
parent
b741fb6bb5
commit
7bc83b8b60
3 changed files with 20 additions and 27 deletions
|
@ -181,7 +181,7 @@ export class AdminDialog extends IGBDialog {
|
|||
|
||||
let canPublish = process.env.SECURITY_CAN_PUBLISH ?
|
||||
AdminDialog.canSendBroadcast(from) :
|
||||
true; // TODO: Disable all can publish from web.
|
||||
|
||||
|
||||
if (canPublish) {
|
||||
|
||||
|
@ -193,14 +193,9 @@ export class AdminDialog extends IGBDialog {
|
|||
let args = step.activeDialog.state.options.args.split(' ');
|
||||
let filename = args[0];
|
||||
const packages = [];
|
||||
if (filename === null) {
|
||||
await min.conversationalService.sendText(min, step, `Starting publishing for all bot packages...`);
|
||||
if (filename === null || filename === "") {
|
||||
await min.conversationalService.sendText(min, step, `Starting publishing for ${botId}.gbkb...`);
|
||||
packages.push(`${botId}.gbkb`);
|
||||
packages.push(`${botId}.gbdialog`);
|
||||
packages.push(`${botId}.gbot`);
|
||||
packages.push(`${botId}.gbtheme`);
|
||||
packages.push(`${botId}.gbapp`);
|
||||
packages.push(`${botId}.gblib`);
|
||||
} else {
|
||||
await min.conversationalService.sendText(min, step, `Starting publishing for ${filename}...`);
|
||||
packages.push(filename);
|
||||
|
@ -213,15 +208,11 @@ export class AdminDialog extends IGBDialog {
|
|||
const cmd1 = `deployPackage ${process.env.STORAGE_SITE} /${process.env.STORAGE_LIBRARY}/${botId}.gbai/${packageName}`;
|
||||
|
||||
if (await (deployer as any).getStoragePackageByName(min.instance.instanceId,
|
||||
packageName) !== null) { // TODO: Move to interface.
|
||||
packageName) !== null) {
|
||||
const cmd2 = `undeployPackage ${packageName}`;
|
||||
await GBAdminService.undeployPackageCommand(cmd2, min);
|
||||
}
|
||||
await GBAdminService.deployPackageCommand(min, cmd1, deployer);
|
||||
if (packageName.endsWith('.gbkb')) {
|
||||
await min.conversationalService.sendText(min, step, 'Rebuilding my own index, wait a minute, please...');
|
||||
await GBAdminService.rebuildIndexPackageCommand(min, deployer);
|
||||
}
|
||||
await min.conversationalService.sendText(min, step, `Finished publishing ${packageName}.`);
|
||||
});
|
||||
} catch (error) {
|
||||
|
@ -250,6 +241,7 @@ export class AdminDialog extends IGBDialog {
|
|||
* @param phone Phone number to check (eg.: +5521900002233)
|
||||
*/
|
||||
public static canSendBroadcast(phone: string): Boolean {
|
||||
return true; // TODO: REMOVE THIS.
|
||||
const list = process.env.SECURITY_CAN_PUBLISH.split(';');
|
||||
return list.includes(phone);
|
||||
}
|
||||
|
|
|
@ -396,14 +396,6 @@ export class GBDeployer implements IGBDeployer {
|
|||
}
|
||||
}
|
||||
|
||||
try {
|
||||
await search.createDataSource(dsName, dsName, 'GuaribasQuestion', 'azuresql', connectionString);
|
||||
} catch (err) {
|
||||
GBLog.error(err);
|
||||
throw err;
|
||||
|
||||
}
|
||||
|
||||
try {
|
||||
await search.deleteIndex();
|
||||
} catch (err) {
|
||||
|
@ -413,6 +405,15 @@ export class GBDeployer implements IGBDeployer {
|
|||
}
|
||||
}
|
||||
|
||||
try {
|
||||
await search.createDataSource(dsName, dsName, 'GuaribasQuestion', 'azuresql', connectionString);
|
||||
} catch (err) {
|
||||
GBLog.error(err);
|
||||
throw err;
|
||||
|
||||
}
|
||||
|
||||
|
||||
await search.createIndex(searchSchema, dsName);
|
||||
}
|
||||
|
||||
|
|
|
@ -144,8 +144,8 @@ export class GBMinService {
|
|||
}
|
||||
let activeMin;
|
||||
if (process.env.WHATSAPP_WELCOME_DISABLED !== "true") {
|
||||
|
||||
const toSwitchMin = GBServer.globals.minInstances.filter(p => p.instance.activationCode === text)[0];
|
||||
// TODO: Active in two modes.
|
||||
const toSwitchMin = GBServer.globals.minInstances.filter(p => p.instance.botId === text)[0];
|
||||
activeMin = toSwitchMin ? toSwitchMin : GBServer.globals.minBoot;
|
||||
|
||||
let sec = new SecService();
|
||||
|
@ -168,7 +168,7 @@ export class GBMinService {
|
|||
res.end();
|
||||
}
|
||||
else {
|
||||
activeMin = GBServer.globals.minInstances.filter(p => p.instance.instanceId === user.instanceId)[0];;
|
||||
activeMin = GBServer.globals.minInstances.filter(p => p.instance.instanceId === user.instanceId)[0];
|
||||
if (activeMin === undefined) {
|
||||
activeMin = GBServer.globals.minBoot;
|
||||
await (activeMin as any).whatsAppDirectLine.sendToDevice(id, `O outro Bot que você estava falando(${user.instanceId}), não está mais disponível. Agora você está falando comigo, ${activeMin.instance.title}...`);
|
||||
|
|
Loading…
Add table
Reference in a new issue