fix: optimize LID migration performance and introduce cache (#1782)

* chore: lid-map cache, bulk migration, fixes

* fix: type error

* fix: signalrepository with lid type, remove check from assertsessions, lid-mapping store level deduplication

* fix: migrations logs

* fix: remove migrationsops lenght check

* fix: skip deletesession if cached or existing migrations

* chore: remove check migrated session

* fix: remove return null loadsession

* fix: getLIDforPN call and jidsrequiringfetch

* fix: longer lid map cache TTL

* fix: lint

* fix: lid type

* fix: lid socket type
This commit is contained in:
Gustavo Quadri
2025-09-14 15:58:59 -03:00
committed by GitHub
parent 42c980778e
commit 194b557b0f
10 changed files with 241 additions and 220 deletions
+7 -5
View File
@@ -76,10 +76,12 @@ export type SignalRepository = {
injectE2ESession(opts: E2ESessionOpts): Promise<void>
validateSession(jid: string): Promise<{ exists: boolean; reason?: string }>
jidToSignalProtocolAddress(jid: string): string
storeLIDPNMapping(lid: string, pn: string): Promise<void>
getLIDMappingStore(): LIDMappingStore
migrateSession(fromJid: string, toJid: string): Promise<void>
migrateSession(fromJids: string[], toJid: string): Promise<{ migrated: number; skipped: number; total: number }>
validateSession(jid: string): Promise<{ exists: boolean; reason?: string }>
deleteSession(jid: string): Promise<void>
destroy(): void
deleteSession(jids: string[]): Promise<void>
}
// Optimized repository with pre-loaded LID mapping store
export interface SignalRepositoryWithLIDStore extends SignalRepository {
lidMapping: LIDMappingStore
}
+2 -2
View File
@@ -6,7 +6,7 @@ import type { ILogger } from '../Utils/logger'
import type { AuthenticationState, SignalAuthState, TransactionCapabilityOptions } from './Auth'
import type { GroupMetadata } from './GroupMetadata'
import { type MediaConnInfo } from './Message'
import type { SignalRepository } from './Signal'
import type { SignalRepositoryWithLIDStore } from './Signal'
export type WAVersion = [number, number, number]
export type WABrowserDescription = [string, string, string]
@@ -153,5 +153,5 @@ export type SocketConfig = {
}[]
| undefined
>
) => SignalRepository
) => SignalRepositoryWithLIDStore
}