signal,messages-send,libsignal: properly parse and ignore hosted devices

This commit is contained in:
Rajeh Taher
2025-10-08 02:25:26 +03:00
parent 54db127303
commit 9e4dbb2e22
3 changed files with 30 additions and 11 deletions
+15 -5
View File
@@ -279,7 +279,7 @@ export const makeMessagesSocket = (config: SocketConfig) => {
const requestedLidUsers = new Set<string>()
for (const jid of toFetch) {
if (jid.includes('@lid')) {
if (jid.includes('@lid') || jid.includes('@hosted.lid')) {
const user = jidDecode(jid)?.user
if (user) requestedLidUsers.add(user)
}
@@ -301,7 +301,12 @@ export const makeMessagesSocket = (config: SocketConfig) => {
await signalRepository.lidMapping.storeLIDPNMappings(lidResults.map(a => ({ lid: a.lid as string, pn: a.id })))
}
const extracted = extractDeviceJids(result?.list, authState.creds.me!.id, ignoreZeroDevices)
const extracted = extractDeviceJids(
result?.list,
authState.creds.me!.id,
authState.creds.me!.lid!,
ignoreZeroDevices
)
const deviceMap: { [_: string]: FullJid[] } = {}
for (const item of extracted) {
@@ -316,8 +321,8 @@ export const makeMessagesSocket = (config: SocketConfig) => {
// Process all devices for this user
for (const item of userDevices) {
const finalJid = isLidUser
? jidEncode(user, item.server === 'hosted' ? 'hosted.lid' : 'lid', item.device)
: jidEncode(item.user, item.server === 'hosted' ? 'hosted' : 's.whatsapp.net', item.device)
? jidEncode(user, item.server, item.device, item.domainType)
: jidEncode(item.user, item.server, item.device, item.domainType)
deviceResults.push({
...item,
@@ -699,7 +704,12 @@ export const makeMessagesSocket = (config: SocketConfig) => {
for (const device of devices) {
const deviceJid = device.jid
const hasKey = !!senderKeyMap[deviceJid]
if ((!hasKey || !!participant) && !isJidHostedLidUser(deviceJid) && !isJidHostedPnUser(deviceJid)) {
if (
(!hasKey || !!participant) &&
!isJidHostedLidUser(deviceJid) &&
!isJidHostedPnUser(deviceJid) &&
device.device !== 99
) {
//todo: revamp all this logic
// the goal is to follow with what I said above for each group, and instead of a true false map of ids, we can set an array full of those the app has already sent pkmsgs
senderKeyRecipients.push(deviceJid)