whalibmob 5.26.0 → 5.26.1
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/Client.js +33 -17
- package/package.json +1 -1
package/lib/Client.js
CHANGED
|
@@ -5461,9 +5461,9 @@ class WhalibmobClient extends EventEmitter {
|
|
|
5461
5461
|
// Web-mode history lands in its own files. A number can be registered over
|
|
5462
5462
|
// SMS and separately linked as a companion, and only the companion ever
|
|
5463
5463
|
// receives history — merging the two would be merging different accounts'
|
|
5464
|
-
// views of the same number.
|
|
5465
|
-
const phone =
|
|
5466
|
-
|
|
5464
|
+
// views of the same number. Same prefix the readers use.
|
|
5465
|
+
const phone = this._sessionFilePrefix();
|
|
5466
|
+
if (!phone) return;
|
|
5467
5467
|
const sessionDir = this._sessionDir;
|
|
5468
5468
|
|
|
5469
5469
|
_whaDbg('[DBG] HIST_SYNC start syncType=' + notification.syncType +
|
|
@@ -5680,15 +5680,25 @@ class WhalibmobClient extends EventEmitter {
|
|
|
5680
5680
|
}
|
|
5681
5681
|
|
|
5682
5682
|
/**
|
|
5683
|
-
*
|
|
5684
|
-
* Returns the parsed {phone}.history.json content or null if not yet synced.
|
|
5683
|
+
* The name every file of this session is built from.
|
|
5685
5684
|
*
|
|
5686
|
-
*
|
|
5685
|
+
* A number can be registered over SMS and separately linked as a companion,
|
|
5686
|
+
* and the two are different accounts' views of it, so the companion's files
|
|
5687
|
+
* carry a `.web` in the middle: 40712345678.web.history.json. Everything that
|
|
5688
|
+
* reads or writes one has to agree on that — a writer that adds the `.web`
|
|
5689
|
+
* and a reader that does not will not error, it will simply never find the
|
|
5690
|
+
* file it just wrote.
|
|
5687
5691
|
*/
|
|
5688
|
-
|
|
5692
|
+
_sessionFilePrefix() {
|
|
5689
5693
|
if (!this._store || !this._store.phoneNumber) return null;
|
|
5694
|
+
return this._store.phoneNumber + (this._mode === 'web' ? '.web' : '');
|
|
5695
|
+
}
|
|
5696
|
+
|
|
5697
|
+
_readSessionJson(suffix) {
|
|
5698
|
+
const prefix = this._sessionFilePrefix();
|
|
5699
|
+
if (!prefix) return null;
|
|
5690
5700
|
const fs = require('fs');
|
|
5691
|
-
const file = require('path').join(this._sessionDir,
|
|
5701
|
+
const file = require('path').join(this._sessionDir, prefix + suffix);
|
|
5692
5702
|
try {
|
|
5693
5703
|
if (!fs.existsSync(file)) return null;
|
|
5694
5704
|
return JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
@@ -5696,19 +5706,25 @@ class WhalibmobClient extends EventEmitter {
|
|
|
5696
5706
|
}
|
|
5697
5707
|
|
|
5698
5708
|
/**
|
|
5699
|
-
*
|
|
5700
|
-
* Returns the parsed {phone}.
|
|
5709
|
+
* getHistoryStore — load the persisted history store for this session.
|
|
5710
|
+
* Returns the parsed {phone}.history.json content — {phone}.web.history.json
|
|
5711
|
+
* on a companion — or null if not yet synced.
|
|
5712
|
+
*
|
|
5713
|
+
* @returns {object|null}
|
|
5714
|
+
*/
|
|
5715
|
+
getHistoryStore() {
|
|
5716
|
+
return this._readSessionJson('.history.json');
|
|
5717
|
+
}
|
|
5718
|
+
|
|
5719
|
+
/**
|
|
5720
|
+
* getMessagesStore — load the persisted messages for this session.
|
|
5721
|
+
* Returns the parsed {phone}.messages.json content — {phone}.web.messages.json
|
|
5722
|
+
* on a companion — or null if not yet synced.
|
|
5701
5723
|
*
|
|
5702
5724
|
* @returns {object|null}
|
|
5703
5725
|
*/
|
|
5704
5726
|
getMessagesStore() {
|
|
5705
|
-
|
|
5706
|
-
const fs = require('fs');
|
|
5707
|
-
const file = require('path').join(this._sessionDir, this._store.phoneNumber + '.messages.json');
|
|
5708
|
-
try {
|
|
5709
|
-
if (!fs.existsSync(file)) return null;
|
|
5710
|
-
return JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
5711
|
-
} catch (_) { return null; }
|
|
5727
|
+
return this._readSessionJson('.messages.json');
|
|
5712
5728
|
}
|
|
5713
5729
|
|
|
5714
5730
|
// ─── Public API ───────────────────────────────────────────────────────────
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "whalibmob",
|
|
3
|
-
"version": "5.26.
|
|
3
|
+
"version": "5.26.1",
|
|
4
4
|
"description": "Node.js library for WhatsApp — register a number over SMS, or link as a companion by QR. Signal E2E encryption, media, groups, channels.",
|
|
5
5
|
"author": "Kunboruto20",
|
|
6
6
|
"main": "index.js",
|