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:
@@ -1150,21 +1150,24 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
|
||||
const lid = jidNormalizedUser(node.attrs.from),
|
||||
pn = jidNormalizedUser(node.attrs.sender_pn)
|
||||
ev.emit('lid-mapping.update', { lid, pn })
|
||||
await signalRepository.storeLIDPNMapping(lid, pn)
|
||||
await signalRepository.lidMapping.storeLIDPNMappings([{ lid, pn }])
|
||||
}
|
||||
|
||||
const alt = msg.key.participantAlt || msg.key.remoteJidAlt
|
||||
// store new mappings we didn't have before
|
||||
if (!!alt) {
|
||||
const altServer = jidDecode(alt)?.server
|
||||
const lidMapping = signalRepository.getLIDMappingStore()
|
||||
if (altServer === 'lid') {
|
||||
if (typeof (await lidMapping.getPNForLID(alt)) === 'string') {
|
||||
await lidMapping.storeLIDPNMapping(alt, msg.key.participant || msg.key.remoteJid!)
|
||||
if (typeof (await signalRepository.lidMapping.getPNForLID(alt)) === 'string') {
|
||||
await signalRepository.lidMapping.storeLIDPNMappings([
|
||||
{ lid: alt, pn: msg.key.participant || msg.key.remoteJid! }
|
||||
])
|
||||
}
|
||||
} else {
|
||||
if (typeof (await lidMapping.getLIDForPN(alt)) === 'string') {
|
||||
await lidMapping.storeLIDPNMapping(msg.key.participant || msg.key.remoteJid!, alt)
|
||||
if (typeof (await signalRepository.lidMapping.getLIDForPN(alt)) === 'string') {
|
||||
await signalRepository.lidMapping.storeLIDPNMappings([
|
||||
{ lid: msg.key.participant || msg.key.remoteJid!, pn: alt }
|
||||
])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user