new(all): Custom Domain support per bot.

This commit is contained in:
rodrigorodriguez 2022-10-02 15:12:52 -03:00
parent 212eb825aa
commit dab35ac77f

View file

@ -140,17 +140,26 @@ export class WhatsappDirectLine extends GBService {
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}`]
};
if (browserWSEndpoint) {
puppeteer = { browserWSEndpoint: browserWSEndpoint };
}
const client = this.customClient = new Client({
authStrategy: new LocalAuth({
clientId: this.min.botId,
dataPath: localName
}),
puppeteer: {browserWSEndpoint:browserWSEndpoint }
puppeteer: puppeteer
});
client.initialize();
this.browserWSEndpoint = client.browser.wsEndpoint();
client.on('message', (async message => {
await this.WhatsAppCallback(message, null);
@ -195,13 +204,11 @@ export class WhatsappDirectLine extends GBService {
};
this.browserWSEndpoint = browser.wsEndpoint(); // store for later
(createClient.bind(this))(this.browserWSEndpoint);
browser.on('disconnected', (async () => {
(createClient.bind(this))(this.browserWSEndpoint);
(createClient.bind(this))(this.browserWSEndpoint);
}).bind(this));
setUrl = false;