Merge branch 'multi-device' into multi-device-legacy

This commit is contained in:
Adhiraj Singh
2021-12-17 19:28:00 +05:30
9 changed files with 558 additions and 119 deletions

View File

@@ -139,6 +139,7 @@ export const makeChatsSocket = (config: SocketConfig) => {
await query({
tag: 'iq',
attrs: {
xmlns: 'blocklist',
to: S_WHATSAPP_NET,
type: 'set'
},
@@ -604,4 +605,4 @@ export const makeChatsSocket = (config: SocketConfig) => {
chatModify,
resyncMainAppState,
}
}
}

View File

@@ -494,9 +494,11 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
const handleReceipt = async(node: BinaryNode) => {
let shouldAck = true
const { attrs, content } = node
const isNodeFromMe = areJidsSameUser(attrs.from, authState.creds.me?.id)
const remoteJid = attrs.recipient || attrs.from
const fromMe = attrs.recipient ? false : true
const fromMe = isNodeFromMe || (attrs.recipient ? false : true)
const ids = [attrs.id]
if(Array.isArray(content)) {
@@ -512,7 +514,7 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
}
const status = getStatusFromReceiptType(attrs.type)
if(typeof status !== 'undefined' && !areJidsSameUser(attrs.from, authState.creds.me?.id)) {
if(typeof status !== 'undefined' && !isNodeFromMe) {
ev.emit('messages.update', ids.map(id => ({
key: { ...key, id },
update: { status }
@@ -520,6 +522,8 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
}
if(attrs.type === 'retry') {
// correctly set who is asking for the retry
key.participant = key.participant || attrs.from
if(key.fromMe) {
try {
logger.debug({ attrs }, 'recv retry request')

View File

@@ -1,5 +1,4 @@
import got from "got"
import { Boom } from "@hapi/boom"
import { SocketConfig, MediaConnInfo, AnyMessageContent, MiscMessageGenerationOptions, WAMediaUploadFunction, MessageRelayOptions } from "../Types"
import { encodeWAMessage, generateMessageID, generateWAMessage, encryptSenderKeyMsgSignalProto, encryptSignalProto, extractDeviceJids, jidToSignalProtocolAddress, parseAndInjectE2ESessions, getWAUploadToServer } from "../Utils"
@@ -30,7 +29,7 @@ export const makeMessagesSocket = (config: SocketConfig) => {
const fetchPrivacySettings = async(force: boolean = false) => {
if(!privacySettings || force) {
const result = await query({
const { content } = await query({
tag: 'iq',
attrs: {
xmlns: 'privacy',
@@ -41,7 +40,7 @@ export const makeMessagesSocket = (config: SocketConfig) => {
{ tag: 'privacy', attrs: { } }
]
})
privacySettings = reduceBinaryNodeToDictionary(result, 'category')
privacySettings = reduceBinaryNodeToDictionary(content[0] as BinaryNode, 'category')
}
return privacySettings
}