whalibmob 5.5.77 → 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 +31 -33
- package/package.json +1 -1
|
@@ -693,52 +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
|
-
//
|
|
708
|
-
//
|
|
709
|
-
//
|
|
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.
|
|
703
|
+
// ── Addressing family ─────────────────────────────────────────────────────
|
|
704
|
+
// Baileys 7.0.0-rc13 — the release that fixed ack 479 on LID addressing —
|
|
705
|
+
// derives the whole address family from the JID the caller passed, and
|
|
706
|
+
// never converts between the two:
|
|
712
707
|
//
|
|
713
|
-
//
|
|
714
|
-
//
|
|
715
|
-
//
|
|
716
|
-
//
|
|
717
|
-
//
|
|
718
|
-
//
|
|
719
|
-
//
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
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
|
|
712
|
+
//
|
|
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;
|
|
728
727
|
|
|
729
728
|
let otherJids;
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
if (useLidRoute) {
|
|
733
|
-
// Fetch bundle + build Signal session for the LID JID.
|
|
734
|
-
// skipUsync=true: we already know the LID from _pnToLid — skip a second
|
|
735
|
-
// 15 s usync round-trip and go straight to bundle fetch (device 0 primary).
|
|
729
|
+
if (isLidTarget) {
|
|
730
|
+
const lidUser = phoneFromJid(toJid);
|
|
736
731
|
const lidDevices = await this._devMgr.bulkEnsureSessionsForLid(
|
|
737
732
|
lidUser, this._signal, allowPkmsg, /* skipUsync */ true);
|
|
738
|
-
otherJids = lidDevices.length > 0 ? lidDevices : [
|
|
733
|
+
otherJids = lidDevices.length > 0 ? lidDevices : [toJid];
|
|
739
734
|
} else {
|
|
740
735
|
otherJids = _recipientDevicesByPhone.length > 0 ? _recipientDevicesByPhone : [toJid];
|
|
741
736
|
}
|
|
737
|
+
|
|
738
|
+
_whaDbg('[DBG] DM_ROUTE to=' + toJid + ' family=' + (isLidTarget ? 'LID' : 'PN') +
|
|
739
|
+
' devices=[' + otherJids.join(',') + ']');
|
|
742
740
|
// ─────────────────────────────────────────────────────────────────────────
|
|
743
741
|
|
|
744
742
|
const ownLinkedJids = ownDevices.filter(j => j !== ownMainJid);
|