Skip to content

Commit

Permalink
fix(core.gbapp): Check of previous bot name before creation.
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigorodriguez committed Jun 11, 2020
1 parent 6306274 commit 0d3bea8
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 29 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@
.env
teste.sql
poc/
*.env
25 changes: 15 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
10 changes: 5 additions & 5 deletions packages/core.gbapp/services/GBDeployer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -408,7 +408,7 @@ export class GBDeployer implements IGBDeployer {
return await service.undeployKbFromStorage(instance, this, p.packageId);

case '.gbui':

break;

case '.gbtheme':
Expand Down
23 changes: 13 additions & 10 deletions packages/core.gbapp/services/GBMinService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion packages/core.gbapp/services/GBVMService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion packages/whatsapp.gblib/services/WhatsappDirectLine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

}
Expand Down

0 comments on commit 0d3bea8

Please sign in to comment.