Skip to content

Commit 8fce53b

Browse files
committed
fixed version whatsapp web for baileys
1 parent 65bba23 commit 8fce53b

File tree

2 files changed

+32
-7
lines changed

2 files changed

+32
-7
lines changed

src/api/services/channels/whatsapp.baileys.service.ts

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -496,13 +496,24 @@ export class BaileysStartupService extends ChannelStartupService {
496496
this.mobile = mobile;
497497
}
498498

499-
const { version } = await fetchLatestBaileysVersion();
500-
501-
this.logger.verbose('Baileys version: ' + version);
502499
const session = this.configService.get<ConfigSessionPhone>('CONFIG_SESSION_PHONE');
503500
const browser: WABrowserDescription = [session.CLIENT, session.NAME, release()];
504501
this.logger.verbose('Browser: ' + JSON.stringify(browser));
505502

503+
let version;
504+
let log;
505+
506+
if (session.VERSION) {
507+
version = session.VERSION.split(',');
508+
log = `Baileys version env: ${version}`;
509+
} else {
510+
const baileysVersion = await fetchLatestBaileysVersion();
511+
version = baileysVersion.version;
512+
log = `Baileys version: ${version}`;
513+
}
514+
515+
this.logger.info(log);
516+
506517
let options;
507518

508519
if (this.localProxy.enabled) {
@@ -540,7 +551,7 @@ export class BaileysStartupService extends ChannelStartupService {
540551
printQRInTerminal: false,
541552
mobile,
542553
browser: number ? ['Chrome (Linux)', session.NAME, release()] : browser,
543-
version: [2, 2413, 1],
554+
version,
544555
markOnlineOnConnect: this.localSettings.always_online,
545556
retryRequestDelayMs: 10,
546557
connectTimeoutMs: 60_000,
@@ -671,10 +682,23 @@ export class BaileysStartupService extends ChannelStartupService {
671682
try {
672683
this.instance.authState = await this.defineAuthState();
673684

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

688+
let version;
689+
let log;
690+
691+
if (session.VERSION) {
692+
version = session.VERSION.split(',');
693+
log = `Baileys version env: ${version}`;
694+
} else {
695+
const baileysVersion = await fetchLatestBaileysVersion();
696+
version = baileysVersion.version;
697+
log = `Baileys version: ${version}`;
698+
}
699+
700+
this.logger.info(log);
701+
678702
let options;
679703

680704
if (this.localProxy.enabled) {
@@ -711,7 +735,7 @@ export class BaileysStartupService extends ChannelStartupService {
711735
logger: P({ level: this.logBaileys }),
712736
printQRInTerminal: false,
713737
browser: this.phoneNumber ? ['Chrome (Linux)', session.NAME, release()] : browser,
714-
version: [2, 2413, 1],
738+
version,
715739
markOnlineOnConnect: this.localSettings.always_online,
716740
retryRequestDelayMs: 10,
717741
connectTimeoutMs: 60_000,

src/config/env.config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ export type CacheConfLocal = {
155155
};
156156
export type SslConf = { PRIVKEY: string; FULLCHAIN: string };
157157
export type Webhook = { GLOBAL?: GlobalWebhook; EVENTS: EventsWebhook };
158-
export type ConfigSessionPhone = { CLIENT: string; NAME: string };
158+
export type ConfigSessionPhone = { CLIENT: string; NAME: string; VERSION: string };
159159
export type QrCode = { LIMIT: number; COLOR: string };
160160
export type Typebot = { API_VERSION: string; KEEP_OPEN: boolean };
161161
export type Chatwoot = {
@@ -360,6 +360,7 @@ export class ConfigService {
360360
CONFIG_SESSION_PHONE: {
361361
CLIENT: process.env?.CONFIG_SESSION_PHONE_CLIENT || 'Evolution API',
362362
NAME: process.env?.CONFIG_SESSION_PHONE_NAME || 'Chrome',
363+
VERSION: process.env?.CONFIG_SESSION_PHONE_VERSION || null,
363364
},
364365
QRCODE: {
365366
LIMIT: Number.parseInt(process.env.QRCODE_LIMIT) || 30,

0 commit comments

Comments
 (0)