mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
feat: resync main app state on new key
This commit is contained in:
@@ -2,12 +2,12 @@ import { SocketConfig, WAPresence, PresenceData, Chat, WAPatchCreate, WAMediaUpl
|
|||||||
import { BinaryNode, getBinaryNodeChild, getBinaryNodeChildren, jidNormalizedUser, S_WHATSAPP_NET } from "../WABinary";
|
import { BinaryNode, getBinaryNodeChild, getBinaryNodeChildren, jidNormalizedUser, S_WHATSAPP_NET } from "../WABinary";
|
||||||
import { proto } from '../../WAProto'
|
import { proto } from '../../WAProto'
|
||||||
import { generateProfilePicture, toNumber, encodeSyncdPatch, decodePatches, extractSyncdPatches, chatModificationToAppPatch } from "../Utils";
|
import { generateProfilePicture, toNumber, encodeSyncdPatch, decodePatches, extractSyncdPatches, chatModificationToAppPatch } from "../Utils";
|
||||||
import { makeMessagesRecvSocket } from "./messages-recv";
|
import { makeMessagesSocket } from "./messages-send";
|
||||||
import makeMutex from "../Utils/make-mutex";
|
import makeMutex from "../Utils/make-mutex";
|
||||||
|
|
||||||
export const makeChatsSocket = (config: SocketConfig) => {
|
export const makeChatsSocket = (config: SocketConfig) => {
|
||||||
const { logger } = config
|
const { logger } = config
|
||||||
const sock = makeMessagesRecvSocket(config)
|
const sock = makeMessagesSocket(config)
|
||||||
const {
|
const {
|
||||||
ev,
|
ev,
|
||||||
ws,
|
ws,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { SocketConfig } from '../Types'
|
import { SocketConfig } from '../Types'
|
||||||
import { DEFAULT_CONNECTION_CONFIG } from '../Defaults'
|
import { DEFAULT_CONNECTION_CONFIG } from '../Defaults'
|
||||||
import { makeChatsSocket as _makeSocket } from './chats'
|
import { makeMessagesRecvSocket as _makeSocket } from './messages-recv'
|
||||||
|
|
||||||
// export the last socket layer
|
// export the last socket layer
|
||||||
const makeWASocket = (config: Partial<SocketConfig>) => (
|
const makeWASocket = (config: Partial<SocketConfig>) => (
|
||||||
|
|||||||
@@ -4,14 +4,14 @@ import { decodeMessageStanza, encodeBigEndian, toNumber, downloadHistory, genera
|
|||||||
import { BinaryNode, jidDecode, jidEncode, isJidStatusBroadcast, areJidsSameUser, getBinaryNodeChildren, jidNormalizedUser, getAllBinaryNodeChildren, BinaryNodeAttributes } from '../WABinary'
|
import { BinaryNode, jidDecode, jidEncode, isJidStatusBroadcast, areJidsSameUser, getBinaryNodeChildren, jidNormalizedUser, getAllBinaryNodeChildren, BinaryNodeAttributes } from '../WABinary'
|
||||||
import { proto } from "../../WAProto"
|
import { proto } from "../../WAProto"
|
||||||
import { KEY_BUNDLE_TYPE } from "../Defaults"
|
import { KEY_BUNDLE_TYPE } from "../Defaults"
|
||||||
import { makeMessagesSocket } from "./messages-send"
|
import { makeChatsSocket } from "./chats"
|
||||||
import { extractGroupMetadata } from "./groups"
|
import { extractGroupMetadata } from "./groups"
|
||||||
|
|
||||||
const isReadReceipt = (type: string) => type === 'read' || type === 'read-self'
|
const isReadReceipt = (type: string) => type === 'read' || type === 'read-self'
|
||||||
|
|
||||||
export const makeMessagesRecvSocket = (config: SocketConfig) => {
|
export const makeMessagesRecvSocket = (config: SocketConfig) => {
|
||||||
const { logger } = config
|
const { logger } = config
|
||||||
const sock = makeMessagesSocket(config)
|
const sock = makeChatsSocket(config)
|
||||||
const {
|
const {
|
||||||
ev,
|
ev,
|
||||||
authState,
|
authState,
|
||||||
@@ -20,6 +20,7 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
|
|||||||
sendNode,
|
sendNode,
|
||||||
relayMessage,
|
relayMessage,
|
||||||
sendDeliveryReceipt,
|
sendDeliveryReceipt,
|
||||||
|
resyncMainAppState,
|
||||||
} = sock
|
} = sock
|
||||||
|
|
||||||
const msgRetryMap = config.msgRetryCounterMap || { }
|
const msgRetryMap = config.msgRetryCounterMap || { }
|
||||||
@@ -166,6 +167,8 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ev.emit('auth-state.update', authState)
|
ev.emit('auth-state.update', authState)
|
||||||
|
|
||||||
|
resyncMainAppState()
|
||||||
break
|
break
|
||||||
case proto.ProtocolMessage.ProtocolMessageType.REVOKE:
|
case proto.ProtocolMessage.ProtocolMessageType.REVOKE:
|
||||||
ev.emit('messages.update', [
|
ev.emit('messages.update', [
|
||||||
|
|||||||
Reference in New Issue
Block a user