mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
fix(master): error in init queries
This commit is contained in:
@@ -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(),
|
||||||
|
|||||||
@@ -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 = {
|
||||||
|
|||||||
@@ -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,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user