libsignal,lid-mapping, etc.: Partially fix "No sessions" on hosted JIDs
This commit is contained in:
@@ -44,8 +44,8 @@ import {
|
||||
getBinaryNodeChildren,
|
||||
getServerFromDomainType,
|
||||
isJidGroup,
|
||||
isJidHostedLidUser,
|
||||
isJidHostedPnUser,
|
||||
isHostedLidUser,
|
||||
isHostedPnUser,
|
||||
isLidUser,
|
||||
isPnUser,
|
||||
jidDecode,
|
||||
@@ -381,6 +381,8 @@ export const makeMessagesSocket = (config: SocketConfig) => {
|
||||
const uniqueJids = [...new Set(jids)] // Deduplicate JIDs
|
||||
const jidsRequiringFetch: string[] = []
|
||||
|
||||
logger.debug({ jids }, 'assertSessions call with jids')
|
||||
|
||||
// Check peerSessionsCache and validate sessions using libsignal loadSession
|
||||
for (const jid of uniqueJids) {
|
||||
const signalId = signalRepository.jidToSignalProtocolAddress(jid)
|
||||
@@ -404,10 +406,10 @@ export const makeMessagesSocket = (config: SocketConfig) => {
|
||||
if (jidsRequiringFetch.length) {
|
||||
// LID if mapped, otherwise original
|
||||
const wireJids = [
|
||||
...jidsRequiringFetch.filter(jid => !!jid.includes('@lid')),
|
||||
...jidsRequiringFetch.filter(jid => !!jid.includes('@lid') || !!jid.includes('@hosted.lid')),
|
||||
...(
|
||||
(await signalRepository.lidMapping.getLIDsForPNs(
|
||||
jidsRequiringFetch.filter(jid => !!jid.includes('@s.whatsapp.net'))
|
||||
jidsRequiringFetch.filter(jid => !!jid.includes('@s.whatsapp.net') || !!jid.includes('@hosted'))
|
||||
)) || []
|
||||
).map(a => a.lid)
|
||||
]
|
||||
@@ -715,8 +717,8 @@ export const makeMessagesSocket = (config: SocketConfig) => {
|
||||
const hasKey = !!senderKeyMap[deviceJid]
|
||||
if (
|
||||
(!hasKey || !!participant) &&
|
||||
!isJidHostedLidUser(deviceJid) &&
|
||||
!isJidHostedPnUser(deviceJid) &&
|
||||
!isHostedLidUser(deviceJid) &&
|
||||
!isHostedPnUser(deviceJid) &&
|
||||
device.device !== 99
|
||||
) {
|
||||
//todo: revamp all this logic
|
||||
@@ -839,7 +841,7 @@ export const makeMessagesSocket = (config: SocketConfig) => {
|
||||
}
|
||||
|
||||
// Check if this is our device (could match either PN or LID user)
|
||||
const isMe = user === mePnUser || (meLidUser && user === meLidUser)
|
||||
const isMe = user === mePnUser || user === meLidUser
|
||||
|
||||
if (isMe) {
|
||||
meRecipients.push(jid)
|
||||
|
||||
Reference in New Issue
Block a user