potential fix for QR scan. the server may expect these messages to be sent on reconnect after scan (#959)

* potential fix for QR scan. the server may expect these messages to be sent on reconnect after scan.

* refactor: extract dictionary reduce code into utility

* refactor: convert the props + abt send req to somewhat useful query

Co-authored-by: Adhiraj Singh <adhirajsingh1001@gmail.com>
This commit is contained in:
HUGEIT
2021-12-03 14:10:26 +01:00
committed by GitHub
parent d9cfed64ff
commit 903871d180
3 changed files with 67 additions and 10 deletions

View File

@@ -1,9 +1,9 @@
import got from "got"
import { Boom } from "@hapi/boom"
import { SocketConfig, MediaConnInfo, AnyMessageContent, MiscMessageGenerationOptions, WAMediaUploadFunction, MessageRelayOptions, WAMessageKey } from "../Types"
import { SocketConfig, MediaConnInfo, AnyMessageContent, MiscMessageGenerationOptions, WAMediaUploadFunction, MessageRelayOptions } from "../Types"
import { encodeWAMessage, generateMessageID, generateWAMessage, encryptSenderKeyMsgSignalProto, encryptSignalProto, extractDeviceJids, jidToSignalProtocolAddress, parseAndInjectE2ESession } from "../Utils"
import { BinaryNode, getBinaryNodeChild, getBinaryNodeChildren, isJidGroup, jidDecode, jidEncode, jidNormalizedUser, S_WHATSAPP_NET, BinaryNodeAttributes, JidWithDevice } from '../WABinary'
import { BinaryNode, getBinaryNodeChild, getBinaryNodeChildren, isJidGroup, jidDecode, jidEncode, jidNormalizedUser, S_WHATSAPP_NET, BinaryNodeAttributes, JidWithDevice, reduceBinaryNodeToDictionary } from '../WABinary'
import { proto } from "../../WAProto"
import { WA_DEFAULT_EPHEMERAL, DEFAULT_ORIGIN, MEDIA_PATH_MAP } from "../Defaults"
import { makeGroupsSocket } from "./groups"
@@ -41,13 +41,7 @@ export const makeMessagesSocket = (config: SocketConfig) => {
{ tag: 'privacy', attrs: { } }
]
})
const nodes = getBinaryNodeChildren(result, 'category')
privacySettings = nodes.reduce(
(dict, { attrs }) => {
dict[attrs.name] = attrs.value
return dict
}, { } as { [_: string]: string }
)
privacySettings = reduceBinaryNodeToDictionary(result, 'category')
}
return privacySettings
}