new(all): Custom Domain support per bot.
This commit is contained in:
parent
8687a4258b
commit
08d8570af1
1 changed files with 15 additions and 13 deletions
|
@ -138,7 +138,7 @@ export class WhatsappDirectLine extends GBService {
|
|||
const gbaiName = `${this.min.botId}.gbai`;
|
||||
const localName = Path.join('work', gbaiName, 'profile');
|
||||
|
||||
const createClient = async (browserWSEndpoint) => {
|
||||
const createClient = (browserWSEndpoint) => {
|
||||
let puppeteer: any = {
|
||||
headless: false, args: ['--disable-features=site-per-process',
|
||||
`--user-data-dir=${localName}`]
|
||||
|
@ -155,6 +155,7 @@ export class WhatsappDirectLine extends GBService {
|
|||
puppeteer: puppeteer
|
||||
});
|
||||
|
||||
client.initialize();
|
||||
|
||||
client.on('message', (async message => {
|
||||
await this.WhatsAppCallback(message, null);
|
||||
|
@ -195,6 +196,12 @@ export class WhatsappDirectLine extends GBService {
|
|||
|
||||
client.on('authenticated', () => {
|
||||
this.browserWSEndpoint = client.pupBrowser.wsEndpoint();
|
||||
|
||||
|
||||
GBLog.info(`WhatsApp QR Code authenticated for ${this.botId}.`);
|
||||
});
|
||||
};
|
||||
|
||||
client.pupBrowser.on('disconnected', (async () => {
|
||||
GBLog.info(`Browser crashed. Restarting ${this.min.botId} WhatsApp native provider.`);
|
||||
await (createClient.bind(this))(null);
|
||||
|
@ -206,14 +213,9 @@ export class WhatsappDirectLine extends GBService {
|
|||
} await (createClient.bind(this))(null);
|
||||
}).bind(this));
|
||||
|
||||
GBLog.info(`WhatsApp QR Code authenticated for ${this.botId}.`);
|
||||
});
|
||||
};
|
||||
(createClient.bind(this))(this.browserWSEndpoint);
|
||||
|
||||
|
||||
await (createClient.bind(this))(this.browserWSEndpoint);
|
||||
await client.initialize();
|
||||
|
||||
setUrl = false;
|
||||
}
|
||||
break;
|
||||
|
|
Loading…
Add table
Reference in a new issue