fix(master): error in init queries

This commit is contained in:
Rajeh Taher
2024-05-06 18:18:15 +03:00
committed by GitHub
parent 27d42652d7
commit fbbb511fb8
3 changed files with 10 additions and 29 deletions

View File

@@ -715,32 +715,6 @@ export const makeChatsSocket = (config: SocketConfig) => {
} }
} }
/** sending abt props may fix QR scan fail if server expects */
const fetchAbt = async() => {
const abtNode = await query({
tag: 'iq',
attrs: {
to: S_WHATSAPP_NET,
xmlns: 'abt',
type: 'get',
},
content: [
{ tag: 'props', attrs: { protocol: '1' } }
]
})
const propsNode = getBinaryNodeChild(abtNode, 'props')
let props: { [_: string]: string } = {}
if(propsNode) {
props = reduceBinaryNodeToDictionary(propsNode, 'prop')
}
logger.debug('fetched abt')
return props
}
/** sending non-abt props may fix QR scan fail if server expects */ /** sending non-abt props may fix QR scan fail if server expects */
const fetchProps = async() => { const fetchProps = async() => {
const resultNode = await query({ const resultNode = await query({
@@ -751,14 +725,20 @@ export const makeChatsSocket = (config: SocketConfig) => {
type: 'get', type: 'get',
}, },
content: [ content: [
{ tag: 'props', attrs: {} } { tag: 'props', attrs: {
protocol: 2,
hash: authState?.creds?.lastPropHash || ""
} }
] ]
}) })
const propsNode = getBinaryNodeChild(resultNode, 'props') const propsNode = getBinaryNodeChild(resultNode, 'props')
let props: { [_: string]: string } = {} let props: { [_: string]: string } = {}
if(propsNode) { if(propsNode) {
authState?.creds?.lastPropHash = propsNode?.attrs?.hash
ev.emit('creds.update', authState.creds)
props = reduceBinaryNodeToDictionary(propsNode, 'prop') props = reduceBinaryNodeToDictionary(propsNode, 'prop')
} }
@@ -841,7 +821,6 @@ export const makeChatsSocket = (config: SocketConfig) => {
* */ * */
const executeInitQueries = async() => { const executeInitQueries = async() => {
await Promise.all([ await Promise.all([
fetchAbt(),
fetchProps(), fetchProps(),
fetchBlocklist(), fetchBlocklist(),
fetchPrivacySettings(), fetchPrivacySettings(),

View File

@@ -68,6 +68,7 @@ export type AuthenticationCreds = SignalCreds & {
backupToken: Buffer backupToken: Buffer
registration: RegistrationOptions registration: RegistrationOptions
pairingCode: string | undefined pairingCode: string | undefined
lastPropHash: string | undefined
} }
export type SignalDataTypeMap = { export type SignalDataTypeMap = {

View File

@@ -216,5 +216,6 @@ export const initAuthCreds = (): AuthenticationCreds => {
backupToken: randomBytes(20), backupToken: randomBytes(20),
registration: {} as never, registration: {} as never,
pairingCode: undefined, pairingCode: undefined,
lastPropHash: undefined,
} }
} }