Add: LID support with lid-map and migrations of sessions (#1694)

* fix: add lid-map logic

* fix: lint and simplified version

* fix: single device migration

* fix: lid map discovery

* fix: lint

* fix: lid migration in socket connection

* fix: lint

* fix: decode-wa-message consistency

* fix: yarn lock

* fix: lint

* fix: retry logic

* fix: logger level
This commit is contained in:
Gustavo Quadri
2025-09-07 08:12:24 -03:00
committed by GitHub
parent 8f21a67e4a
commit 0043f8be21
10 changed files with 968 additions and 77 deletions
+19
View File
@@ -759,6 +759,25 @@ export const makeSocket = (config: SocketConfig) => {
ev.emit('creds.update', { me: { ...authState.creds.me!, lid: node.attrs.lid } })
ev.emit('connection.update', { connection: 'open' })
if (node.attrs.lid && authState.creds.me?.id) {
const myLID = node.attrs.lid
process.nextTick(async () => {
try {
const myPN = authState.creds.me!.id
// Store our own LID-PN mapping
await signalRepository.storeLIDPNMapping(myLID, myPN)
// Create LID session for ourselves (whatsmeow pattern)
await signalRepository.migrateSession(myPN, myLID)
logger.info({ myPN, myLID }, 'Own LID session created successfully')
} catch (error) {
logger.error({ error, lid: myLID }, 'Failed to create own LID session')
}
})
}
})
ws.on('CB:stream:error', (node: BinaryNode) => {