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.
@@ -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
- // First, run the phone-based usync (and own devices) in parallel.
697
- // IMPORTANT: _pnToLid may be empty RIGHT NOW but gets populated during this
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
- // ── LID routing fix ───────────────────────────────────────────────────────
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
- // keeps the stanza addressed to the JID the caller passed:
722
- // const finalJid = jid;
723
- // const destinationJid = !isStatus ? finalJid : statusJid;
724
- // It never rewrites `to` to the LID. The LID is used only to look up
725
- // devices, fetch prekeys and address the per-device <to> entries; the
726
- // envelope stays on the phone JID. Rewriting the envelope is what draws
727
- // 479, which both whatsmeow #859 and the Baileys LID reports describe as
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
- // WA_DM_ROUTE=lid restores the old envelope-on-LID behaviour for
731
- // comparison; anything else keeps the Baileys shape.
732
- const routeMode = (process.env.WA_DM_ROUTE || 'auto').toLowerCase();
733
- const lidUser = this._client._pnToLid && this._client._pnToLid.get(recipientPhone);
734
- // Participants still come from the LID device list whenever we know it —
735
- // that part matches Baileys too, which encodes @lid per-device JIDs while
736
- // leaving the envelope alone.
737
- const useLidRoute = !!lidUser;
738
- const routingToJid = (lidUser && routeMode === 'lid') ? `${lidUser}@lid` : toJid;
739
-
740
- _whaDbg('[DBG] DM_ROUTE phone=' + recipientPhone +
741
- ' envelope=' + routingToJid + ' participants=' +
742
- (useLidRoute ? 'LID' : 'PN') + ' mode=' + routeMode);
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
- // Follow the same address family as the routing JID — the participants and
746
- // the `to` must agree, so WA_DM_ROUTE=pn has to switch both.
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 : [routingToJid];
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);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "whalibmob",
3
- "version": "5.5.78",
3
+ "version": "5.5.80",
4
4
  "description": "WhatsApp library for interaction with WhatsApp Mobile API no web",
5
5
  "author": "Kunboruto50",
6
6
  "main": "index.js",