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:
@@ -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) => {
|
||||
|
||||
Reference in New Issue
Block a user