fix: Resolve generation of pairing code

In this commit, we have fixed an issue related to the generation of the pairing code. The changes include modifying the `whatsapp.baileys.service.ts` file, where we have updated the `connectToWhatsapp` method to accept a phone number parameter. Additionally, we have made changes to the `browser` variable to handle phone number and browser options. These changes improve the reliability of the pairing code generation.
This commit is contained in:
Davidson Gomes 2024-06-26 13:55:11 -03:00
parent 47d6fd5d31
commit d0eee796ba

View File

@ -366,7 +366,7 @@ export class BaileysStartupService extends ChannelStartupService {
if (connection === 'close') { if (connection === 'close') {
const shouldReconnect = (lastDisconnect.error as Boom)?.output?.statusCode !== DisconnectReason.loggedOut; const shouldReconnect = (lastDisconnect.error as Boom)?.output?.statusCode !== DisconnectReason.loggedOut;
if (shouldReconnect) { if (shouldReconnect) {
await this.connectToWhatsapp(); await this.connectToWhatsapp(this.phoneNumber);
} else { } else {
this.sendDataWebhook(Events.STATUS_INSTANCE, { this.sendDataWebhook(Events.STATUS_INSTANCE, {
instance: this.instance.name, instance: this.instance.name,
@ -512,7 +512,19 @@ export class BaileysStartupService extends ChannelStartupService {
this.instance.authState = await this.defineAuthState(); this.instance.authState = await this.defineAuthState();
const session = this.configService.get<ConfigSessionPhone>('CONFIG_SESSION_PHONE'); const session = this.configService.get<ConfigSessionPhone>('CONFIG_SESSION_PHONE');
const browser: WABrowserDescription = [session.CLIENT, session.NAME, release()];
let browserOptions = {};
if (number || this.phoneNumber) {
this.phoneNumber = number;
this.logger.info(`Phone number: ${number}`);
} else {
const browser: WABrowserDescription = [session.CLIENT, session.NAME, release()];
browserOptions = { browser };
this.logger.info(`Browser: ${browser}`);
}
let version; let version;
let log; let log;
@ -575,7 +587,7 @@ export class BaileysStartupService extends ChannelStartupService {
}, },
logger: P({ level: this.logBaileys }), logger: P({ level: this.logBaileys }),
printQRInTerminal: false, printQRInTerminal: false,
browser: number ? ['Chrome (Linux)', session.NAME, release()] : browser, ...browserOptions,
version, version,
markOnlineOnConnect: this.localSettings.alwaysOnline, markOnlineOnConnect: this.localSettings.alwaysOnline,
retryRequestDelayMs: 350, retryRequestDelayMs: 350,
@ -643,7 +655,17 @@ export class BaileysStartupService extends ChannelStartupService {
this.instance.authState = await this.defineAuthState(); this.instance.authState = await this.defineAuthState();
const session = this.configService.get<ConfigSessionPhone>('CONFIG_SESSION_PHONE'); const session = this.configService.get<ConfigSessionPhone>('CONFIG_SESSION_PHONE');
const browser: WABrowserDescription = [session.CLIENT, session.NAME, release()];
let browserOptions = {};
if (this.phoneNumber) {
this.logger.info(`Phone number: ${this.phoneNumber}`);
} else {
const browser: WABrowserDescription = [session.CLIENT, session.NAME, release()];
browserOptions = { browser };
this.logger.info(`Browser: ${browser}`);
}
let version; let version;
let log; let log;
@ -706,7 +728,7 @@ export class BaileysStartupService extends ChannelStartupService {
}, },
logger: P({ level: this.logBaileys }), logger: P({ level: this.logBaileys }),
printQRInTerminal: false, printQRInTerminal: false,
browser: this.phoneNumber ? ['Chrome (Linux)', session.NAME, release()] : browser, ...browserOptions,
version, version,
markOnlineOnConnect: this.localSettings.alwaysOnline, markOnlineOnConnect: this.localSettings.alwaysOnline,
retryRequestDelayMs: 350, retryRequestDelayMs: 350,