fix: send message speed, lid logic, remove messages-send useless functions (#1794)

* fix: remove redundant migration

* fix: remove deduplicatelidpnjids

* fix: assertsessions complexity

* fix: assertsessions call

* fix: remove getencryptionjid

* fix: add wirejid to injecte2esession, remove libsignal lid migration

* fix: logger lid-mapping

* fix: injecte2esession decoded approach

* fix: changes made by @AstroX11

* fix: lint

* fix: lint

* fix: lint

* Revert "fix: injecte2esession decoded approach"

This reverts commit 4e368296ed084398b8a173ec117dc2478e481748.

* fix: centralize getlidforpn calls in messages-send

* fix: add resolvechunklids to signal

* fix: remove useless arrays

* fix: assertsessions logic

* fix: lint

* Revert "fix: assertsessions logic"

This reverts commit 65b0730891c91573edcab1c96af010db54382fba.

* fix: remove onwhatsapp fallback to prevent rate limit, migrate sessions when lid-map is created, new migration logic and user devices key

* fix: migrate session devices, socket creation

* fix: add back decryptionjid validation

* fix: add resolveSignalAddress to get lid

* fix: type error migration

* fix: lint

* fix: device level cache, proposed changes
This commit is contained in:
Gustavo Quadri
2025-09-26 00:53:15 -03:00
committed by GitHub
parent e965385841
commit ae456cb342
11 changed files with 340 additions and 518 deletions
+19 -6
View File
@@ -42,6 +42,7 @@ import {
getBinaryNodeChild,
getBinaryNodeChildren,
isLidUser,
jidDecode,
jidEncode,
S_WHATSAPP_NET
} from '../WABinary'
@@ -272,9 +273,13 @@ export const makeSocket = (config: SocketConfig) => {
const results = await executeUSyncQuery(usyncQuery)
if (results) {
if (results.list.filter(a => !!a.lid).length > 0) {
const lidOnly = results.list.filter(a => !!a.lid)
await signalRepository.lidMapping.storeLIDPNMappings(lidOnly.map(a => ({ pn: a.id, lid: a.lid as string })))
const lidOnly = results.list.filter(a => !!a.lid)
if (lidOnly.length > 0) {
const pairs = lidOnly.map(a => ({ pn: a.id, lid: a.lid as string }))
await signalRepository.lidMapping.storeLIDPNMappings(pairs)
for (const { pn, lid } of pairs) {
await signalRepository.migrateSession(pn, lid)
}
}
return results.list
@@ -288,7 +293,7 @@ export const makeSocket = (config: SocketConfig) => {
const { creds } = authState
// add transaction capability
const keys = addTransactionCapability(authState.keys, logger, transactionOpts)
const signalRepository = makeSignalRepository({ creds, keys }, onWhatsApp)
const signalRepository = makeSignalRepository({ creds, keys }, logger, onWhatsApp)
let lastDateRecv: Date
let epoch = 1
@@ -853,8 +858,16 @@ export const makeSocket = (config: SocketConfig) => {
// Store our own LID-PN mapping
await signalRepository.lidMapping.storeLIDPNMappings([{ lid: myLID, pn: myPN }])
// Create LID session for ourselves (whatsmeow pattern)
await signalRepository.migrateSession([myPN], myLID)
// Create device list for our own user (needed for bulk migration)
const { user, device } = jidDecode(myPN)!
await authState.keys.set({
'device-list': {
[user]: [device?.toString() || '0']
}
})
// migrate our own session
await signalRepository.migrateSession(myPN, myLID)
logger.info({ myPN, myLID }, 'Own LID session created successfully')
} catch (error) {