Merge pull request #1362 from vai-projetos/readAJid

This commit is contained in:
Cassio Santos
2025-04-22 21:44:16 -03:00
committed by GitHub

View File

@@ -1,5 +1,6 @@
import { promisify } from 'util'
import { inflate } from 'zlib'
import logger from '../Utils/logger'
import * as constants from './constants'
import { jidEncode } from './jid-utils'
import type { BinaryNode, BinaryNodeCodingOptions } from './types'
@@ -147,11 +148,23 @@ export const decodeDecompressedBinaryNode = (
}
const readAdJid = () => {
const agent = readByte()
const rawDomainType = readByte()
const domainType = Number(rawDomainType)
const device = readByte()
const user = readString(readByte())
return jidEncode(user, agent === 0 ? 's.whatsapp.net' : 'lid', device)
if((domainType & 1) !== 0 || (domainType & 0x80) === 0) {
if(![0, 1].includes(domainType)) {
logger.warn('Possibly invalid domainType:', domainType, user, device)
}
}
return jidEncode(
user,
domainType === 0 || domainType === 128 ? 's.whatsapp.net' : 'lid',
device
)
}
const readString = (tag: number): string => {