fix(whatsapp.gblib): Fix in bot switching.

This commit is contained in:
Rodrigo Rodriguez 2023-09-03 16:22:03 -03:00
parent 1e8b66f9b4
commit d7e00a2154
2 changed files with 15 additions and 3 deletions

View file

@ -108,6 +108,10 @@ export class GBDeployer implements IGBDeployer {
if (min['cacheToken']) {
return min['cacheToken'];
} else {
// Get token as root only if the bot does not have
// an custom tenant for retrieving packages.
token = await (min.adminService as any)['acquireElevatedToken']
(min.instance.instanceId, min.instance.authenticatorTenant?false:true);

View file

@ -60,10 +60,18 @@ export class GBImporter {
localPath: string,
additionalInstance: IGBInstance = null
) {
const settingsJson = JSON.parse(Fs.readFileSync(urlJoin(localPath, 'settings.json'), 'utf8'));
if (botId === undefined) {
botId = settingsJson.botId;
const file = urlJoin(localPath, 'settings.json');
let settingsJson = {botId: botId};
if (Fs.existsSync(file)){
settingsJson = JSON.parse(Fs.readFileSync(file, 'utf8'));
if (botId === undefined) {
botId = settingsJson.botId;
}
}
let instance: IGBInstance;
if (botId === undefined) {
botId = GBConfigService.get('BOT_ID');