From 0aa358aa98a9effbfad4bef9ac3d4ccdf67d8fa5 Mon Sep 17 00:00:00 2001 From: rodrigorodriguez Date: Sun, 2 Oct 2022 14:25:11 -0300 Subject: [PATCH] new(all): Custom Domain support per bot. --- packages/core.gbapp/services/GBSSR.ts | 30 ++++++++++--------- .../services/WhatsappDirectLine.ts | 6 ++-- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/packages/core.gbapp/services/GBSSR.ts b/packages/core.gbapp/services/GBSSR.ts index 075da8a0..ff778ac0 100644 --- a/packages/core.gbapp/services/GBSSR.ts +++ b/packages/core.gbapp/services/GBSSR.ts @@ -81,22 +81,24 @@ const RENDER_CACHE = new Map(); -async function createBrowser(profile): Promise { - const gbaiName = `${this.min.botId}.gbai`; - let localName = Path.join('work', gbaiName, 'profile'); +async function createBrowser(profilePath): Promise { + + let args = [ + '--ignore-certificate-errors', + '--no-sandbox', + '--disable-setuid-sandbox', + '--window-size=1920,1080', + "--disable-accelerated-2d-canvas", + "--disable-gpu", + "--disable-features=site-per-process" + ]; + + if (profilePath){ + args.push(`--user-data-dir=${profilePath}`); + } const browser = await puppeteer.launch({ - args: [ - '--ignore-certificate-errors', - '--no-sandbox', - '--disable-setuid-sandbox', - '--window-size=1920,1080', - "--disable-accelerated-2d-canvas", - "--disable-gpu", - "--disable-features=site-per-process", - `--user-data-dir=${localName}` - - ], + args: args, ignoreHTTPSErrors: true, headless: false, }); diff --git a/packages/whatsapp.gblib/services/WhatsappDirectLine.ts b/packages/whatsapp.gblib/services/WhatsappDirectLine.ts index 56856c6d..df67ee8c 100644 --- a/packages/whatsapp.gblib/services/WhatsappDirectLine.ts +++ b/packages/whatsapp.gblib/services/WhatsappDirectLine.ts @@ -136,10 +136,10 @@ export class WhatsappDirectLine extends GBService { // Initialize the browser using a local profile for each bot. const gbaiName = `${this.min.botId}.gbai`; - let localName = Path.join('work', gbaiName, 'profile'); + const localName = Path.join('work', gbaiName, 'profile'); - const browser = await createBrowser(null); - let client = this.customClient = new Client({ + const browser = await createBrowser(localName); + const client = this.customClient = new Client({ authStrategy: new LocalAuth({ clientId: this.min.botId, dataPath: localName