Skip to content

Commit

Permalink
fixed version whatsapp web for baileys
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidsonGomes committed May 21, 2024
1 parent 65bba23 commit 8fce53b
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 7 deletions.
36 changes: 30 additions & 6 deletions src/api/services/channels/whatsapp.baileys.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -496,13 +496,24 @@ export class BaileysStartupService extends ChannelStartupService {
this.mobile = mobile;
}

const { version } = await fetchLatestBaileysVersion();

this.logger.verbose('Baileys version: ' + version);
const session = this.configService.get<ConfigSessionPhone>('CONFIG_SESSION_PHONE');
const browser: WABrowserDescription = [session.CLIENT, session.NAME, release()];
this.logger.verbose('Browser: ' + JSON.stringify(browser));

let version;
let log;

if (session.VERSION) {
version = session.VERSION.split(',');
log = `Baileys version env: ${version}`;
} else {
const baileysVersion = await fetchLatestBaileysVersion();
version = baileysVersion.version;
log = `Baileys version: ${version}`;
}

this.logger.info(log);

let options;

if (this.localProxy.enabled) {
Expand Down Expand Up @@ -540,7 +551,7 @@ export class BaileysStartupService extends ChannelStartupService {
printQRInTerminal: false,
mobile,
browser: number ? ['Chrome (Linux)', session.NAME, release()] : browser,
version: [2, 2413, 1],
version,
markOnlineOnConnect: this.localSettings.always_online,
retryRequestDelayMs: 10,
connectTimeoutMs: 60_000,
Expand Down Expand Up @@ -671,10 +682,23 @@ export class BaileysStartupService extends ChannelStartupService {
try {
this.instance.authState = await this.defineAuthState();

// const { version } = await fetchLatestBaileysVersion();
const session = this.configService.get<ConfigSessionPhone>('CONFIG_SESSION_PHONE');
const browser: WABrowserDescription = [session.CLIENT, session.NAME, release()];

let version;
let log;

if (session.VERSION) {
version = session.VERSION.split(',');
log = `Baileys version env: ${version}`;
} else {
const baileysVersion = await fetchLatestBaileysVersion();
version = baileysVersion.version;
log = `Baileys version: ${version}`;
}

this.logger.info(log);

let options;

if (this.localProxy.enabled) {
Expand Down Expand Up @@ -711,7 +735,7 @@ export class BaileysStartupService extends ChannelStartupService {
logger: P({ level: this.logBaileys }),
printQRInTerminal: false,
browser: this.phoneNumber ? ['Chrome (Linux)', session.NAME, release()] : browser,
version: [2, 2413, 1],
version,
markOnlineOnConnect: this.localSettings.always_online,
retryRequestDelayMs: 10,
connectTimeoutMs: 60_000,
Expand Down
3 changes: 2 additions & 1 deletion src/config/env.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ export type CacheConfLocal = {
};
export type SslConf = { PRIVKEY: string; FULLCHAIN: string };
export type Webhook = { GLOBAL?: GlobalWebhook; EVENTS: EventsWebhook };
export type ConfigSessionPhone = { CLIENT: string; NAME: string };
export type ConfigSessionPhone = { CLIENT: string; NAME: string; VERSION: string };
export type QrCode = { LIMIT: number; COLOR: string };
export type Typebot = { API_VERSION: string; KEEP_OPEN: boolean };
export type Chatwoot = {
Expand Down Expand Up @@ -360,6 +360,7 @@ export class ConfigService {
CONFIG_SESSION_PHONE: {
CLIENT: process.env?.CONFIG_SESSION_PHONE_CLIENT || 'Evolution API',
NAME: process.env?.CONFIG_SESSION_PHONE_NAME || 'Chrome',
VERSION: process.env?.CONFIG_SESSION_PHONE_VERSION || null,
},
QRCODE: {
LIMIT: Number.parseInt(process.env.QRCODE_LIMIT) || 30,
Expand Down

0 comments on commit 8fce53b

Please sign in to comment.