fix(core.gbapp): Check of previous bot name before creation.

This commit is contained in:
Rodrigo Rodriguez 2020-06-11 09:47:59 -03:00
parent 6306274db9
commit 0d3bea80e0
8 changed files with 39 additions and 29 deletions

1
.gitignore vendored
View file

@ -21,3 +21,4 @@
.env
teste.sql
poc/
*.env

25
package-lock.json generated
View file

@ -53,9 +53,9 @@
}
},
"@azure/cosmos": {
"version": "3.6.3",
"resolved": "https://registry.npmjs.org/@azure/cosmos/-/cosmos-3.6.3.tgz",
"integrity": "sha512-JoCDxl0TnL6EHL4xD3KC9r2bMivK13q1jl7h69wd/YFLlt3aBTTCehtAX+y4alNSENpL53XdRdw/cna0mI2XDw==",
"version": "3.7.0",
"resolved": "https://registry.npmjs.org/@azure/cosmos/-/cosmos-3.7.0.tgz",
"integrity": "sha512-3SRxnmy6NncdX5eYqGuRTack52hloS9YhQ0aOKwWJ8Z4dDSrVH3XB2Mcp/WokoIpVm0Bq5nUC8FsvLBZKfRkyg==",
"requires": {
"@types/debug": "^4.1.4",
"debug": "^4.1.1",
@ -66,13 +66,18 @@
"priorityqueuejs": "^1.0.0",
"semaphore": "^1.0.5",
"tslib": "^1.10.0",
"uuid": "^3.3.2"
"uuid": "^8.1.0"
},
"dependencies": {
"tslib": {
"version": "1.13.0",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.13.0.tgz",
"integrity": "sha512-i/6DQjL8Xf3be4K/E6Wgpekn5Qasl1usyw++dAA35Ue5orEn65VIxOA+YvNNl9HV3qv70T7CNwjODHZrLwvd1Q=="
},
"uuid": {
"version": "8.1.0",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.1.0.tgz",
"integrity": "sha512-CI18flHDznR0lq54xBycOVmphdCYnQLKn8abKn7PXUiKUGdEd+/l9LWNJmugXel4hXq7S+RMNl34ecyC9TntWg=="
}
}
},
@ -3141,9 +3146,9 @@
},
"dependencies": {
"@types/node": {
"version": "10.17.24",
"resolved": "https://registry.npmjs.org/@types/node/-/node-10.17.24.tgz",
"integrity": "sha512-5SCfvCxV74kzR3uWgTYiGxrd69TbT1I6+cMx1A5kEly/IVveJBimtAMlXiEyVFn5DvUFewQWxOOiJhlxeQwxgA=="
"version": "10.17.26",
"resolved": "https://registry.npmjs.org/@types/node/-/node-10.17.26.tgz",
"integrity": "sha512-myMwkO2Cr82kirHY8uknNRHEVtn0wV3DTQfkrjx17jmkstDRZ24gNUdl8AHXVyVclTYI/bNjgTPTAWvWLqXqkw=="
}
}
},
@ -3273,9 +3278,9 @@
}
},
"botlib": {
"version": "1.5.5",
"resolved": "https://registry.npmjs.org/botlib/-/botlib-1.5.5.tgz",
"integrity": "sha512-fugvHvp0XDqAflOFxbLknC49ijDL0P0c8DDztLSj2sUfwoJ6J2YqVIU8kkVW1OdjNGvXCNUjiZS6ZHEuHaGdMQ==",
"version": "1.5.6",
"resolved": "https://registry.npmjs.org/botlib/-/botlib-1.5.6.tgz",
"integrity": "sha512-wcTe6xoJ+NK5RUE6CoEMnnrKs/09IdCmRNRJmeiDPWU/bmL2JgMoeY4/owDFstEflV+uffZmNliT6cMvnAqWeA==",
"requires": {
"async": "3.1.0",
"botbuilder": "4.7.0",

View file

@ -66,7 +66,7 @@
"botbuilder-ai": "4.7.0",
"botbuilder-dialogs": "4.7.0",
"botframework-connector": "4.7.0",
"botlib": "1.5.6",
"botlib": "1.5.7",
"cli-spinner": "0.2.10",
"dotenv-extended": "2.7.1",
"exceljs": "3.5.0",

View file

@ -219,7 +219,8 @@ export class AzureDeployerService implements IGBInstallationDeployer {
};
}
public async botExists(botId, group) {
public async botExists(botId) {
const group = GBConfigService.get('CLOUD_GROUP');
const baseUrl = `https://management.azure.com/`;
const username = GBConfigService.get('CLOUD_USERNAME');
const password = GBConfigService.get('CLOUD_PASSWORD');

View file

@ -174,9 +174,9 @@ export class GBDeployer implements IGBDeployer {
return await this.deployBotFull(instance, GBServer.globals.publicAddress);
}
public async botExists(instance: IGBInstance, group, publicAddress: string): Promise<boolean> {
public async botExists(botId: string): Promise<boolean> {
const service = new AzureDeployerService(this);
return await service.botExists(instance.botId, group);
return await service.botExists(botId);
}
/**
* Deploys a bot to the storage.
@ -191,7 +191,7 @@ export class GBDeployer implements IGBDeployer {
const group = GBConfigService.get('CLOUD_GROUP');
const subscriptionId = GBConfigService.get('CLOUD_SUBSCRIPTIONID');
if (await service.botExists(instance.botId, group)) {
if (await service.botExists(instance.botId)) {
await service.updateBot(
instance.botId,
group,
@ -312,7 +312,7 @@ export class GBDeployer implements IGBDeployer {
const group = GBConfigService.get('CLOUD_GROUP');
if (await service.botExists(botId, group)) {
if (await service.botExists(botId)) {
await service.deleteBot(
botId, group

View file

@ -480,16 +480,19 @@ export class GBMinService {
}
else {
const minBoot = GBServer.globals.minBoot as any;
min.whatsAppDirectLine =
new WhatsappDirectLine(
min,
min.botId,
min.instance.webchatKey,
minBoot.instance.whatsappServiceKey,
minBoot.instance.whatsappServiceNumber,
minBoot.instance.whatsappServiceUrl
);
await min.whatsAppDirectLine.setup(false);
if (minBoot.instance.whatsappServiceKey) {
min.whatsAppDirectLine =
new WhatsappDirectLine(
min,
min.botId,
min.instance.webchatKey,
minBoot.instance.whatsappServiceKey,
minBoot.instance.whatsappServiceNumber,
minBoot.instance.whatsappServiceUrl
);
await min.whatsAppDirectLine.setup(false);
}
}
min.userProfile = conversationState.createProperty('userProfile');

View file

@ -218,7 +218,7 @@ export class GBVMService extends GBService {
// Convert TS into JS.
const tsfile: string = `${filename}.ts`;
let tsCode: string = fs.readFileSync(tsfile, 'utf8');
tsCode = tsCode.replace(/export.*\n/gi, `export function ${mainName}(step:any) { let resolve = undefined;`);
tsCode = tsCode.replace(/export.*\n/gi, `export function ${mainName}(step:any) { let resolve;`);
fs.writeFileSync(tsfile, tsCode);
const tsc = new TSCompiler();

View file

@ -244,7 +244,7 @@ export class WhatsappDirectLine extends GBService {
}
else {
GBLog.info(`USER (${id}) TO AGENT ${user.userSystemId}: ${text}`);
this.sendToDeviceEx(user.agentSystemId, `${id}: ${text}`, locale);
this.sendToDeviceEx(user.agentSystemId, `Bot: ${this.min.instance.botId}\n${id}: ${text}`, locale);
}
}