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:
@@ -271,10 +271,9 @@ export const makeSocket = (config: SocketConfig) => {
|
||||
const results = await executeUSyncQuery(usyncQuery)
|
||||
|
||||
if (results) {
|
||||
if (results.list.filter(a => a.lid).length > 0) {
|
||||
const lidMapping = signalRepository.getLIDMappingStore()
|
||||
const lidOnly = results.list.filter(a => a.lid)
|
||||
await lidMapping.storeLIDPNMappings(lidOnly.map(a => ({ pn: a.id, lid: a.lid as string })))
|
||||
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 })))
|
||||
}
|
||||
|
||||
return results.list
|
||||
@@ -851,10 +850,10 @@ export const makeSocket = (config: SocketConfig) => {
|
||||
const myPN = authState.creds.me!.id
|
||||
|
||||
// Store our own LID-PN mapping
|
||||
await signalRepository.storeLIDPNMapping(myLID, myPN)
|
||||
await signalRepository.lidMapping.storeLIDPNMappings([{ lid: myLID, pn: myPN }])
|
||||
|
||||
// Create LID session for ourselves (whatsmeow pattern)
|
||||
await signalRepository.migrateSession(myPN, myLID)
|
||||
await signalRepository.migrateSession([myPN], myLID)
|
||||
|
||||
logger.info({ myPN, myLID }, 'Own LID session created successfully')
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user