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 { proto } from '../../WAProto'
|
||||
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";
|
||||
|
||||
export const makeChatsSocket = (config: SocketConfig) => {
|
||||
const { logger } = config
|
||||
const sock = makeMessagesRecvSocket(config)
|
||||
const sock = makeMessagesSocket(config)
|
||||
const {
|
||||
ev,
|
||||
ws,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { SocketConfig } from '../Types'
|
||||
import { DEFAULT_CONNECTION_CONFIG } from '../Defaults'
|
||||
import { makeChatsSocket as _makeSocket } from './chats'
|
||||
import { makeMessagesRecvSocket as _makeSocket } from './messages-recv'
|
||||
|
||||
// export the last socket layer
|
||||
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 { proto } from "../../WAProto"
|
||||
import { KEY_BUNDLE_TYPE } from "../Defaults"
|
||||
import { makeMessagesSocket } from "./messages-send"
|
||||
import { makeChatsSocket } from "./chats"
|
||||
import { extractGroupMetadata } from "./groups"
|
||||
|
||||
const isReadReceipt = (type: string) => type === 'read' || type === 'read-self'
|
||||
|
||||
export const makeMessagesRecvSocket = (config: SocketConfig) => {
|
||||
const { logger } = config
|
||||
const sock = makeMessagesSocket(config)
|
||||
const sock = makeChatsSocket(config)
|
||||
const {
|
||||
ev,
|
||||
authState,
|
||||
@@ -20,6 +20,7 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
|
||||
sendNode,
|
||||
relayMessage,
|
||||
sendDeliveryReceipt,
|
||||
resyncMainAppState,
|
||||
} = sock
|
||||
|
||||
const msgRetryMap = config.msgRetryCounterMap || { }
|
||||
@@ -166,6 +167,8 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
|
||||
}
|
||||
|
||||
ev.emit('auth-state.update', authState)
|
||||
|
||||
resyncMainAppState()
|
||||
break
|
||||
case proto.ProtocolMessage.ProtocolMessageType.REVOKE:
|
||||
ev.emit('messages.update', [
|
||||
|
||||
Reference in New Issue
Block a user