From d563c0f5edc2e1e33e67feca7c54691196dfeecb Mon Sep 17 00:00:00 2001 From: rodrigorodriguez Date: Sun, 2 Oct 2022 15:27:53 -0300 Subject: [PATCH] new(all): Custom Domain support per bot. --- .../whatsapp.gblib/services/WhatsappDirectLine.ts | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/packages/whatsapp.gblib/services/WhatsappDirectLine.ts b/packages/whatsapp.gblib/services/WhatsappDirectLine.ts index 56cb9b10..753326bf 100644 --- a/packages/whatsapp.gblib/services/WhatsappDirectLine.ts +++ b/packages/whatsapp.gblib/services/WhatsappDirectLine.ts @@ -138,9 +138,7 @@ export class WhatsappDirectLine extends GBService { const gbaiName = `${this.min.botId}.gbai`; const localName = Path.join('work', gbaiName, 'profile'); - const browser = await createBrowser(localName); - - const createClient = (browserWSEndpoint) => { + const createClient = (browserWSEndpoint) => { let puppeteer: any = { headless: false, args: ['--disable-features=site-per-process', `--user-data-dir=${localName}`] @@ -202,15 +200,15 @@ export class WhatsappDirectLine extends GBService { GBLog.info(`WhatsApp QR Code authenticated for ${this.botId}.`); }); - }; + client.browser.on('disconnected', (async () => { + (createClient.bind(this))(this.browserWSEndpoint); + }).bind(this)); + + }; (createClient.bind(this))(this.browserWSEndpoint); - browser.on('disconnected', (async () => { - (createClient.bind(this))(this.browserWSEndpoint); - }).bind(this)); - setUrl = false; } break;