diff --git a/backend/src/libs/wbot.ts b/backend/src/libs/wbot.ts index faf6026..ae49acd 100644 --- a/backend/src/libs/wbot.ts +++ b/backend/src/libs/wbot.ts @@ -2,7 +2,6 @@ import * as Sentry from "@sentry/node"; import makeWASocket, { WASocket, DisconnectReason, - fetchLatestBaileysVersion, makeCacheableSignalKeyStore, makeInMemoryStore, isJidBroadcast, @@ -85,6 +84,21 @@ function getGreaterVersion(a, b) { return a; } +const waVersion = [2, 3000, 1015891883]; + +const getProjectWAVersion = async () => { + try { + const res = await fetch( + "https://raw.githubusercontent.com/ticketz-oss/ticketz/refs/heads/main/backend/src/waversion.json" + ); + const version = await res.json(); + return version; + } catch (error) { + console.warn("Failed to get current WA Version from project repository"); + } + return waVersion; +}; + export const initWASocket = async (whatsapp: Whatsapp): Promise => { return new Promise((resolve, reject) => { try { @@ -99,13 +113,12 @@ export const initWASocket = async (whatsapp: Whatsapp): Promise => { const { id, name, provider } = whatsappUpdate; - const { version: autoVersion, isLatest } = - await fetchLatestBaileysVersion(); + const autoVersion = await getProjectWAVersion(); const isLegacy = provider === "stable"; - const version = getGreaterVersion(autoVersion, [2, 3000, 1015891883]); + const version = getGreaterVersion(autoVersion, waVersion); - logger.info(`using WA v${version.join(".")}, isLatest: ${isLatest}`); + logger.info(`using WA v${version.join(".")}`); logger.info(`isLegacy: ${isLegacy}`); logger.info(`Starting session ${name}`); let retriesQrCode = 0; diff --git a/backend/src/waversion.json b/backend/src/waversion.json new file mode 100644 index 0000000..4d602aa --- /dev/null +++ b/backend/src/waversion.json @@ -0,0 +1 @@ +[2, 3000, 1015891883] \ No newline at end of file