whalibmob 5.5.78 → 5.5.80
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/messages/MessageSender.js +30 -47
- package/package.json +1 -1
|
@@ -693,67 +693,50 @@ class MessageSender {
|
|
|
693
693
|
// they simply omit the device-identity node (server accepts this for primaries).
|
|
694
694
|
const allowPkmsg = true;
|
|
695
695
|
|
|
696
|
-
//
|
|
697
|
-
//
|
|
698
|
-
// await — incoming messages from the recipient (which arrive while we wait
|
|
699
|
-
// for the usync timeout) tell us their LID JID via from=LID + sender_pn attrs.
|
|
700
|
-
// We therefore check _pnToLid AFTER this await, not before.
|
|
696
|
+
// Enumerate the recipient's devices and our own in parallel — Baileys does
|
|
697
|
+
// the same in one getUSyncDevices([senderIdentity, jid]) call.
|
|
701
698
|
const [_recipientDevicesByPhone, ownDevices] = await Promise.all([
|
|
702
699
|
this._devMgr.bulkEnsureSessions([recipientPhone], this._signal, allowPkmsg),
|
|
703
700
|
this._devMgr.ensureOwnDeviceSessions(ownPhone, this._signal, allowPkmsg)
|
|
704
701
|
]);
|
|
705
702
|
|
|
706
|
-
// ──
|
|
707
|
-
// Check _pnToLid NOW — after the await above, incoming messages from the
|
|
708
|
-
// recipient during the usync wait will have populated this map.
|
|
709
|
-
// For LID-migrated accounts, the message `to` field AND Signal participants
|
|
710
|
-
// must use the LID JID. Phone-JID messages are silently accepted by the
|
|
711
|
-
// server but never delivered to the recipient's LID-registered device.
|
|
712
|
-
//
|
|
713
|
-
// WA_DM_ROUTE overrides the choice for diagnosis, because both routes have
|
|
714
|
-
// been observed failing in different ways and only a live account can tell
|
|
715
|
-
// them apart:
|
|
716
|
-
// pn — always address the phone JID (how this worked before LID JIDs
|
|
717
|
-
// started being decoded at all)
|
|
718
|
-
// lid — always address the LID when one is known (the default below)
|
|
719
|
-
// auto — same as lid; the default
|
|
703
|
+
// ── Addressing family ─────────────────────────────────────────────────────
|
|
720
704
|
// Baileys 7.0.0-rc13 — the release that fixed ack 479 on LID addressing —
|
|
721
|
-
//
|
|
722
|
-
//
|
|
723
|
-
//
|
|
724
|
-
//
|
|
725
|
-
//
|
|
726
|
-
//
|
|
727
|
-
//
|
|
728
|
-
// appearing specifically when the message is addressed to an @lid.
|
|
705
|
+
// derives the whole address family from the JID the caller passed, and
|
|
706
|
+
// never converts between the two:
|
|
707
|
+
//
|
|
708
|
+
// const targetUserServer = isLid ? 'lid' : 's.whatsapp.net'
|
|
709
|
+
// const senderIdentity = isLid && meLid ? <ourLid> : <ourPn>
|
|
710
|
+
// const sessionDevices = await getUSyncDevices([senderIdentity, jid])
|
|
711
|
+
// const finalJid = jid // the envelope, unchanged
|
|
729
712
|
//
|
|
730
|
-
//
|
|
731
|
-
//
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
//
|
|
735
|
-
//
|
|
736
|
-
//
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
713
|
+
// Send to a phone JID and everything — envelope, device enumeration,
|
|
714
|
+
// participant <to> entries — stays on phone JIDs. Send to an @lid and it
|
|
715
|
+
// all stays LID.
|
|
716
|
+
//
|
|
717
|
+
// This used to look the recipient up in _pnToLid and rewrite a
|
|
718
|
+
// phone-addressed DM into a LID-addressed one, on the reasoning that a
|
|
719
|
+
// phone-addressed message is accepted but never delivered to a
|
|
720
|
+
// LID-registered device. That rewrite is what produced the 479s: every
|
|
721
|
+
// rejected stanza in the traces carried to="...@lid", and both
|
|
722
|
+
// whatsmeow #859 and the Baileys LID reports describe the ack as appearing
|
|
723
|
+
// specifically on @lid-addressed sends. Following the caller's JID removes
|
|
724
|
+
// the mismatch instead of trying to compensate for it.
|
|
725
|
+
const isLidTarget = toJid.endsWith('@lid');
|
|
726
|
+
const routingToJid = toJid;
|
|
743
727
|
|
|
744
728
|
let otherJids;
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
if (useLidRoute) {
|
|
748
|
-
// Fetch bundle + build Signal session for the LID JID.
|
|
749
|
-
// skipUsync=true: we already know the LID from _pnToLid — skip a second
|
|
750
|
-
// 15 s usync round-trip and go straight to bundle fetch (device 0 primary).
|
|
729
|
+
if (isLidTarget) {
|
|
730
|
+
const lidUser = phoneFromJid(toJid);
|
|
751
731
|
const lidDevices = await this._devMgr.bulkEnsureSessionsForLid(
|
|
752
732
|
lidUser, this._signal, allowPkmsg, /* skipUsync */ true);
|
|
753
|
-
otherJids = lidDevices.length > 0 ? lidDevices : [
|
|
733
|
+
otherJids = lidDevices.length > 0 ? lidDevices : [toJid];
|
|
754
734
|
} else {
|
|
755
735
|
otherJids = _recipientDevicesByPhone.length > 0 ? _recipientDevicesByPhone : [toJid];
|
|
756
736
|
}
|
|
737
|
+
|
|
738
|
+
_whaDbg('[DBG] DM_ROUTE to=' + toJid + ' family=' + (isLidTarget ? 'LID' : 'PN') +
|
|
739
|
+
' devices=[' + otherJids.join(',') + ']');
|
|
757
740
|
// ─────────────────────────────────────────────────────────────────────────
|
|
758
741
|
|
|
759
742
|
const ownLinkedJids = ownDevices.filter(j => j !== ownMainJid);
|