whalibmob 5.6.3 → 5.6.4
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 +26 -3
- package/lib/messages/MessageSender.js +12 -3
- package/package.json +1 -1
package/lib/DeviceManager.js
CHANGED
|
@@ -901,7 +901,10 @@ class DeviceManager {
|
|
|
901
901
|
}
|
|
902
902
|
}
|
|
903
903
|
|
|
904
|
-
|
|
904
|
+
// Same rule as the phone-addressed path: skip the device we are, not the
|
|
905
|
+
// device that happens to be numbered zero.
|
|
906
|
+
const selfDevice = this._ownDeviceIndex();
|
|
907
|
+
const deviceIds = (this._dcGet(cacheKey) || []).filter(d => d !== selfDevice);
|
|
905
908
|
const deviceJids = deviceIds.map(d => makeDeviceJid(lidUser, d, 'lid'));
|
|
906
909
|
if (deviceJids.length === 0) return [];
|
|
907
910
|
|
|
@@ -1085,10 +1088,30 @@ class DeviceManager {
|
|
|
1085
1088
|
// On the first call we query usync, on all subsequent calls we return
|
|
1086
1089
|
// from cache — zero extra network round-trips.
|
|
1087
1090
|
//
|
|
1091
|
+
// Which device index this client occupies.
|
|
1092
|
+
//
|
|
1093
|
+
// A device registered over SMS is the account's primary and is always 0. A
|
|
1094
|
+
// companion linked by pairing code occupies a numbered slot — and then
|
|
1095
|
+
// device 0 is the owner's phone, which is a recipient like any other.
|
|
1096
|
+
_ownDeviceIndex() {
|
|
1097
|
+
const store = this._client && this._client._store;
|
|
1098
|
+
return (store && store.deviceIndex) || 0;
|
|
1099
|
+
}
|
|
1100
|
+
|
|
1088
1101
|
async ensureOwnDeviceSessions(ownPhone, signalProto, allowPkmsg = true) {
|
|
1102
|
+
// Everything the account owns except the device doing the sending.
|
|
1103
|
+
//
|
|
1104
|
+
// This used to drop device 0 unconditionally, which is right only while we
|
|
1105
|
+
// are device 0. As a companion it silently excluded the owner's own phone
|
|
1106
|
+
// from every message we sent: the recipient got it, the phone did not, and
|
|
1107
|
+
// it sat there showing "waiting for this message" forever. It also put our
|
|
1108
|
+
// participant list out of step with the server's, which is what the phash
|
|
1109
|
+
// mismatch on the ack was reporting.
|
|
1110
|
+
const selfDevice = this._ownDeviceIndex();
|
|
1111
|
+
|
|
1089
1112
|
// Use cached own device list if it hasn't expired (5-min TTL matches _deviceCache)
|
|
1090
1113
|
if (this._ownDeviceJids !== null && Date.now() < this._ownDeviceExpiry) {
|
|
1091
|
-
const others = this._ownDeviceJids.filter(j => stripUser(j).device !==
|
|
1114
|
+
const others = this._ownDeviceJids.filter(j => stripUser(j).device !== selfDevice);
|
|
1092
1115
|
return this._ensureSessions(others, signalProto, allowPkmsg);
|
|
1093
1116
|
}
|
|
1094
1117
|
|
|
@@ -1097,7 +1120,7 @@ class DeviceManager {
|
|
|
1097
1120
|
this._ownDeviceJids = deviceJids;
|
|
1098
1121
|
this._ownDeviceExpiry = Date.now() + 5 * 60 * 1000;
|
|
1099
1122
|
|
|
1100
|
-
const others = deviceJids.filter(j => stripUser(j).device !==
|
|
1123
|
+
const others = deviceJids.filter(j => stripUser(j).device !== selfDevice);
|
|
1101
1124
|
return this._ensureSessions(others, signalProto, allowPkmsg);
|
|
1102
1125
|
}
|
|
1103
1126
|
|
|
@@ -1259,8 +1259,8 @@ class MessageSender {
|
|
|
1259
1259
|
: Promise.resolve([]),
|
|
1260
1260
|
// Our own linked devices, in the address family the stanza is routed with.
|
|
1261
1261
|
// ensureOwnDeviceSessions hands back @s.whatsapp.net JIDs, which cannot go
|
|
1262
|
-
// into a stanza carrying addressing_mode='lid'; both helpers
|
|
1263
|
-
//
|
|
1262
|
+
// into a stanza carrying addressing_mode='lid'; both helpers leave out the
|
|
1263
|
+
// device we are, which is device 0 only while we are the primary.
|
|
1264
1264
|
useLid
|
|
1265
1265
|
? this._devMgr.ensureOwnLidDeviceSessions(myLidUser, ownPhone, this._signal)
|
|
1266
1266
|
: this._devMgr.ensureOwnDeviceSessions(ownPhone, this._signal)
|
|
@@ -1275,8 +1275,17 @@ class MessageSender {
|
|
|
1275
1275
|
const s = String(jid);
|
|
1276
1276
|
return s.endsWith('@hosted') || s.endsWith('@hosted.lid');
|
|
1277
1277
|
};
|
|
1278
|
+
// The sending device counts in the enumeration even though it is not a
|
|
1279
|
+
// recipient — and that is *this* device, not device 0. On a companion link
|
|
1280
|
+
// the bare JID names the owner's phone, which arrives through ownTargets
|
|
1281
|
+
// like every other device; adding it here again while leaving our own slot
|
|
1282
|
+
// out would hash a set the server never computes.
|
|
1283
|
+
const ownSelfJid = (useLid
|
|
1284
|
+
? this._client._ownDeviceLidJid()
|
|
1285
|
+
: this._client._ownDeviceJid()) || selfJid;
|
|
1286
|
+
|
|
1278
1287
|
const enumeratedDevices = [...new Set(
|
|
1279
|
-
[...memberDevices, ...lidDevices, ...ownTargets,
|
|
1288
|
+
[...memberDevices, ...lidDevices, ...ownTargets, ownSelfJid]
|
|
1280
1289
|
)].filter(jid => !isHostedJid(jid));
|
|
1281
1290
|
|
|
1282
1291
|
// The participant hash the server checks the fan-out against. whatsmeow puts
|