Skip to content

Commit 74a8d60

Browse files
committed
fix: deliver receipts
1 parent 499974c commit 74a8d60

7 files changed

Lines changed: 41 additions & 5 deletions

File tree

docs/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ This repository currently pins the published npm package `@whiskeysockets/bailey
5252
- Fresh WhatsApp startup uses the Android Baileys browser profile by default for view-once media support. The `/pairwithcode` flow can temporarily restart into `macos-chrome` because pairing codes are more reliable with that profile.
5353
- When WA2DC sees registered WhatsApp auth without a matching saved browser-profile marker, it clears only the WhatsApp auth state and asks you to pair again. This prevents older sessions from being reused blindly under a different browser profile.
5454
- WA2DC also keeps rc11 reconnects on the initial-sync wait path when history sync is enabled, but skips Baileys startup buffering when history sync is disabled; this avoids packaged-startup heap spikes seen after switching existing sessions to the Android browser profile.
55+
- WA2DC keeps `markOnlineOnConnect: false` so your phone can keep receiving WhatsApp notifications, but patches rc11 so inbound non-newsletter messages still send normal delivered receipts instead of the downgraded `inactive` receipt.
5556
- WA2DC logs bounded WhatsApp startup memory probes and patches rc11 LID migration/tctoken pruning paths, so large auth stores do not trigger single huge heap allocations while the socket is coming online.
5657
- The Signal auth store seeds the newly required `lid-mapping`, `tctoken`, `device-list`, and `device-index` namespaces so rc11 can write those blobs safely.
5758

docs/dev/runtime-and-layout.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ WhatsApp startup guardrails:
2525
- Do not eagerly call `groupFetchAllParticipating()` on WhatsApp reconnect or `/resync`. Group metadata is refreshed through live group events and `/resync` uses a lightweight `@g.us` participating-groups query that does not request every participant roster/description; full all-groups fetches can allocate very large Baileys response structures after pairing.
2626
- Pass Baileys a bounded logger wrapper instead of the root pino logger. Baileys errors can include bundled `data:text/javascript;base64...` stack traces and binary payloads; keep those summarized so `logs.txt` and `terminal.log` stay useful and do not drive heap pressure.
2727
- Keep WhatsApp startup memory probes around socket creation, WA connection, real initial buffer flushes, and LID session migration. These probes are intentionally small structured logs used to diagnose packaged OOM rollbacks.
28-
- The Baileys rc11 postinstall patch skips startup event buffering when history sync is disabled, avoids buffer-and-immediate-flush on the disabled-history path, and bounds tctoken pruning so large auth stores do not trigger single huge heap allocations while the socket is coming online.
28+
- The Baileys rc11 postinstall patch skips startup event buffering when history sync is disabled, avoids buffer-and-immediate-flush on the disabled-history path, preserves delivered receipts for inbound messages while WA2DC stays unavailable, and bounds tctoken pruning so large auth stores do not trigger single huge heap allocations while the socket is coming online.
2929

3030
## Developer quick start
3131

docs/dev/testing-and-release.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Release pipeline builds packaged binaries from a pkg-safe CJS runtime bundle:
3030
- release builds publish a signed `${binary}.runtime.tar.gz` archive for each packaged binary so `/update` can refresh the sidecar automatically
3131
- packaged startup may download that signed runtime archive on demand when a packaged install is missing `runtime/`
3232
- runtime may branch on `process.pkg` for packaged-vs-source behavior
33-
- `postinstall` patches Baileys rc11 for the Android browser profile, disabled-history startup buffering, LID migration probes, and bounded tctoken pruning; release builds must run after that patch has been applied
33+
- `postinstall` patches Baileys rc11 for the Android browser profile, disabled-history startup buffering, inbound delivered receipts while unavailable, LID migration probes, and bounded tctoken pruning; release builds must run after that patch has been applied
3434

3535
## Packaging-safe dependency rules
3636

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "wa2dc",
3-
"version": "2.4.0-alpha.2",
3+
"version": "2.4.0-alpha.3",
44
"description": "WhatsAppToDiscord is a Discord bot that uses WhatsApp Web as a bridge between Discord and WhatsApp",
55
"type": "module",
66
"main": "src/runner.js",

scripts/patchBaileysAndroidBrowser.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,15 @@ const boundedTcTokenPruneAfter = ` const TC_TOKEN_PRUNE_BATCH_SIZE = 250;
261261
}
262262
}`;
263263

264+
const preserveDeliveredReceiptWhileUnavailableBefore = ` else if (!sendActiveReceipts) {
265+
type = 'inactive';
266+
}`;
267+
268+
const preserveDeliveredReceiptWhileUnavailableAfter = ` else if (!sendActiveReceipts) {
269+
// WA2DC stays unavailable on connect so the phone keeps getting notifications,
270+
// but inbound messages should still acknowledge delivery to the sender.
271+
}`;
272+
264273
const replacements = [
265274
{
266275
file: "lib/Utils/browser-utils.js",
@@ -370,6 +379,12 @@ const replacements = [
370379
before: boundedTcTokenPruneBefore,
371380
after: boundedTcTokenPruneAfter,
372381
},
382+
{
383+
file: "lib/Socket/messages-recv.js",
384+
marker: "WA2DC stays unavailable on connect so the phone keeps getting notifications",
385+
before: preserveDeliveredReceiptWhileUnavailableBefore,
386+
after: preserveDeliveredReceiptWhileUnavailableAfter,
387+
},
373388
];
374389

375390
const replaceOnce = async ({ file, marker, before, after }) => {

tests/baileysAndroidBrowserPatch.test.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,3 +106,23 @@ test("Baileys rc11 tctoken prune is bounded during startup", () => {
106106
/const allTokens = await authState\.keys\.get\('tctoken', jids\)/u,
107107
);
108108
});
109+
110+
test("Baileys rc11 preserves delivered receipts while WA2DC stays unavailable", () => {
111+
const messagesRecvSource = fs.readFileSync(
112+
"node_modules/@whiskeysockets/baileys/lib/Socket/messages-recv.js",
113+
"utf8",
114+
);
115+
116+
assert.match(
117+
messagesRecvSource,
118+
/WA2DC stays unavailable on connect so the phone keeps getting notifications/u,
119+
);
120+
assert.doesNotMatch(
121+
messagesRecvSource,
122+
/else if \(!sendActiveReceipts\) \{\s*type = 'inactive';\s*\}/u,
123+
);
124+
assert.match(
125+
messagesRecvSource,
126+
/await sendReceipt\(msg\.key\.remoteJid, participant, \[msg\.key\.id\], type\)/u,
127+
);
128+
});

0 commit comments

Comments
 (0)