mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
feat: (hopefully) correctly implement account timestamp sync
This commit is contained in:
@@ -472,18 +472,23 @@ export const makeChatsSocket = (config: SocketConfig) => {
|
|||||||
ws.on('CB:presence', handlePresenceUpdate)
|
ws.on('CB:presence', handlePresenceUpdate)
|
||||||
ws.on('CB:chatstate', handlePresenceUpdate)
|
ws.on('CB:chatstate', handlePresenceUpdate)
|
||||||
|
|
||||||
/*ws.on('CB:ib,,dirty', async(node: BinaryNode) => {
|
ws.on('CB:ib,,dirty', async(node: BinaryNode) => {
|
||||||
const { attrs } = getBinaryNodeChild(node, 'dirty')
|
const { attrs } = getBinaryNodeChild(node, 'dirty')
|
||||||
const type = attrs.type
|
const type = attrs.type
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case 'account_sync':
|
case 'account_sync':
|
||||||
await updateAccountSyncTimestamp(attrs.timestamp)
|
let { lastAccountSyncTimestamp } = authState.creds
|
||||||
|
if(lastAccountSyncTimestamp) {
|
||||||
|
await updateAccountSyncTimestamp(lastAccountSyncTimestamp)
|
||||||
|
}
|
||||||
|
lastAccountSyncTimestamp = +attrs.timestamp
|
||||||
|
ev.emit('creds.update', { lastAccountSyncTimestamp })
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
logger.info({ node }, `received unknown sync`)
|
logger.info({ node }, `received unknown sync`)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
})*/
|
})
|
||||||
|
|
||||||
ws.on('CB:notification,type:server_sync', (node: BinaryNode) => {
|
ws.on('CB:notification,type:server_sync', (node: BinaryNode) => {
|
||||||
const update = getBinaryNodeChild(node, 'collection')
|
const update = getBinaryNodeChild(node, 'collection')
|
||||||
|
|||||||
@@ -39,6 +39,8 @@ export type AuthenticationCreds = SignalCreds & {
|
|||||||
firstUnuploadedPreKeyId: number
|
firstUnuploadedPreKeyId: number
|
||||||
serverHasPreKeys: boolean
|
serverHasPreKeys: boolean
|
||||||
nextPreKeyId: number
|
nextPreKeyId: number
|
||||||
|
|
||||||
|
lastAccountSyncTimestamp?: number
|
||||||
}
|
}
|
||||||
|
|
||||||
type Awaitable<T> = T | Promise<T>
|
type Awaitable<T> = T | Promise<T>
|
||||||
|
|||||||
Reference in New Issue
Block a user