whalibmob 5.5.78 → 5.5.81
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/DeviceManager.js +22 -1
- package/lib/messages/MessageSender.js +30 -47
- package/package.json +1 -1
package/lib/DeviceManager.js
CHANGED
|
@@ -718,7 +718,7 @@ class DeviceManager {
|
|
|
718
718
|
// 2. Establishes Signal sessions for LID device JIDs (e.g. 139471160877194:0@lid)
|
|
719
719
|
// 3. Returns the list of ready LID device JIDs for participant fanout
|
|
720
720
|
//
|
|
721
|
-
async bulkEnsureSessionsForLid(lidUser, signalProto, allowPkmsg = true, skipUsync = false) {
|
|
721
|
+
async bulkEnsureSessionsForLid(lidUser, signalProto, allowPkmsg = true, skipUsync = false, _isRetry = false) {
|
|
722
722
|
const lidJid = `${lidUser}@lid`;
|
|
723
723
|
const cacheKey = `lid:${lidUser}`;
|
|
724
724
|
|
|
@@ -812,6 +812,27 @@ class DeviceManager {
|
|
|
812
812
|
}
|
|
813
813
|
}
|
|
814
814
|
|
|
815
|
+
// Every enumerated device must end up with a session, because every one of
|
|
816
|
+
// them becomes a <to><enc> entry. Coming up short means the cached device
|
|
817
|
+
// list no longer matches the account: a device that has since been unlinked
|
|
818
|
+
// is still listed, the server has no bundle for it, and the stanza goes out
|
|
819
|
+
// missing an entry the server still expects — which it rejects with ack 479.
|
|
820
|
+
//
|
|
821
|
+
// Seen exactly that way in a live trace: five devices enumerated from cache
|
|
822
|
+
// (0, 49, 51, 55, 57), four bundles returned, device 51 left without a
|
|
823
|
+
// session, four participants sent, 479 back.
|
|
824
|
+
//
|
|
825
|
+
// Drop the stale list and re-enumerate once, so the participants match what
|
|
826
|
+
// the server currently believes the account has.
|
|
827
|
+
if (readyJids.length < deviceJids.length && !_isRetry) {
|
|
828
|
+
_whaDbg('[DBG] LID_DEVICE_LIST_STALE lidUser=' + lidUser +
|
|
829
|
+
' enumerated=' + deviceJids.length + ' sessions=' + readyJids.length +
|
|
830
|
+
' — re-running usync\n');
|
|
831
|
+
this._dcDel([cacheKey]);
|
|
832
|
+
return this.bulkEnsureSessionsForLid(
|
|
833
|
+
lidUser, signalProto, allowPkmsg, /* skipUsync */ false, /* _isRetry */ true);
|
|
834
|
+
}
|
|
835
|
+
|
|
815
836
|
// Fallback: use primary LID device 0 directly (no session yet, will use pkmsg)
|
|
816
837
|
if (readyJids.length === 0) {
|
|
817
838
|
readyJids.push(makeDeviceJid(lidUser, 0, 'lid'));
|
|
@@ -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);
|