mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
fix: update fetchLatestWaWebVersion to retrieve client revision from new endpoint (#1234)
This commit is contained in:
@@ -288,16 +288,31 @@ export const fetchLatestBaileysVersion = async(options: AxiosRequestConfig<{}> =
|
|||||||
*/
|
*/
|
||||||
export const fetchLatestWaWebVersion = async(options: AxiosRequestConfig<{}>) => {
|
export const fetchLatestWaWebVersion = async(options: AxiosRequestConfig<{}>) => {
|
||||||
try {
|
try {
|
||||||
const result = await axios.get(
|
const { data } = await axios.get(
|
||||||
'https://web.whatsapp.com/check-update?version=1&platform=web',
|
'https://web.whatsapp.com/sw.js',
|
||||||
{
|
{
|
||||||
...options,
|
...options,
|
||||||
responseType: 'json'
|
responseType: 'json'
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
const version = result.data.currentVersion.split('.')
|
|
||||||
|
const regex = /\\?"client_revision\\?":\s*(\d+)/
|
||||||
|
const match = data.match(regex)
|
||||||
|
|
||||||
|
if(!match?.[1]) {
|
||||||
|
return {
|
||||||
|
version: baileysVersion as WAVersion,
|
||||||
|
isLatest: false,
|
||||||
|
error: {
|
||||||
|
message: 'Could not find client revision in the fetched content'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const clientRevision = match[1]
|
||||||
|
|
||||||
return {
|
return {
|
||||||
version: [+version[0], +version[1], +version[2]] as WAVersion,
|
version: [2, 3000, +clientRevision] as WAVersion,
|
||||||
isLatest: true
|
isLatest: true
|
||||||
}
|
}
|
||||||
} catch(error) {
|
} catch(error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user