messages-send, signal: improve hosted device support + patch cache
This commit is contained in:
@@ -5,7 +5,7 @@ import type { LIDMapping, SignalAuthState, SignalKeyStoreWithTransaction } from
|
||||
import type { SignalRepositoryWithLIDStore } from '../Types/Signal'
|
||||
import { generateSignalPubKey } from '../Utils'
|
||||
import type { ILogger } from '../Utils/logger'
|
||||
import { jidDecode, transferDevice, WAJIDDomains } from '../WABinary'
|
||||
import { isHostedLidUser, isHostedPnUser, isLidUser, isPnUser, jidDecode, transferDevice, WAJIDDomains } from '../WABinary'
|
||||
import type { SenderKeyStore } from './Group/group_cipher'
|
||||
import { SenderKeyName } from './Group/sender-key-name'
|
||||
import { SenderKeyRecord } from './Group/sender-key-record'
|
||||
@@ -181,10 +181,10 @@ export function makeLibSignalRepository(
|
||||
toJid: string
|
||||
): Promise<{ migrated: number; skipped: number; total: number }> {
|
||||
// TODO: use usync to handle this entire mess
|
||||
if (!fromJid || !toJid.includes('@lid')) return { migrated: 0, skipped: 0, total: 0 }
|
||||
if (!fromJid || (!isLidUser(toJid) && !isHostedLidUser(toJid))) return { migrated: 0, skipped: 0, total: 0 }
|
||||
|
||||
// Only support PN to LID migration
|
||||
if (!fromJid.includes('@s.whatsapp.net')) {
|
||||
if (!isPnUser(fromJid) && !isHostedPnUser(fromJid)) {
|
||||
return { migrated: 0, skipped: 0, total: 1 }
|
||||
}
|
||||
|
||||
@@ -222,7 +222,10 @@ export function makeLibSignalRepository(
|
||||
const deviceStr = sessionKey.split('.')[1]
|
||||
if (!deviceStr) continue
|
||||
const deviceNum = parseInt(deviceStr)
|
||||
const jid = deviceNum === 0 ? `${user}@s.whatsapp.net` : `${user}:${deviceNum}@s.whatsapp.net`
|
||||
let jid = deviceNum === 0 ? `${user}@s.whatsapp.net` : `${user}:${deviceNum}@s.whatsapp.net`
|
||||
if (deviceNum == 99) {
|
||||
jid = `${user}:99@hosted`
|
||||
}
|
||||
deviceJids.push(jid)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user