Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

docs: record the participant-arity patch and its per-participant outcome

Yudhi Armyndharis22c0115e925f
diff --git a/docs/29-engine-capability-matrix.md b/docs/29-engine-capability-matrix.md
index 855bc0db5..a4fb8aac6 100644
--- a/docs/29-engine-capability-matrix.md
+++ b/docs/29-engine-capability-matrix.md
@@ -5,7 +5,7 @@ Three-way comparison of every capability: the **Baileys library** (`@whiskeysock
its adapter layer and REST API β€” including which "supported" cells only work because OpenWA patches
the installed library. Coverage is total: all 112 `IWhatsAppEngine` methods (29.4), **all 152
Baileys + 81 whatsapp-web.js library methods** (29.5), all 34 + 31 library events (29.5.4), and all
-6 install-time patches (29.3). If it exists upstream or in OpenWA, it has a row here.
+7 install-time patches (29.3). If it exists upstream or in OpenWA, it has a row here.
## 29.1 How to read this matrix
@@ -124,7 +124,7 @@ OpenWA ships five exact, self-disabling source transforms over the installed eng
patcher no-ops once the fix is present upstream, and an unrecognized source shape fails loudly
rather than shipping a silently partial patch.
-### 29.3.1 The six patches
+### 29.3.1 The seven patches
| # | Patcher | Library target | What it repairs | Stand-down predicate |
| --- | ---------------------------------------------------------- | ------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
@@ -134,10 +134,11 @@ rather than shipping a silently partial patch.
| πŸ”§β΄ | `scripts/patch-wwebjs-ready-sync.js` | whatsapp-web.js readiness pipeline | Two live-observed races: on a warm profile the page can reach `hasSynced=true` before the edge listener attaches (the whole post-auth pipeline silently never runs), and a partial `attachEventListeners` failure was swallowed (message bridge dead while sends still work). Adds an `eventsAttached` completion marker and fires the handler once when the level is already true; double-fire is deduped by the adapter. | exact-shape, one group all-or-nothing; unknown shape fails the build. |
| πŸ”§β΅ | `scripts/patch-baileys-appstate.js` | Baileys `lib/Socket/chats.js` | `resyncAppState`'s `while (collectionsToHandle.size)` loop: `query()` resolves `undefined` on its own 60s timeout, decoding to `{}`, and every loop exit β€” including the library's own attempts guard β€” lives inside `for (const key in decoded)`, which never runs on an empty decode. The loop would burn one 60s query per pass for the life of the socket (~1000 wasted queries/day). The patch adds the missing exit: empty decode β†’ `break`. | exact-shape match; remove once upstream bounds the loop. |
| πŸ”§βΆ | `scripts/patch-baileys-newsletter-create.js` | Baileys `lib/Socket/newsletter.js` | `parseNewsletterCreateResponse` reads `thread.picture.id` eagerly, but `newsletterCreate` sends only `{ name, description }` β€” there is no picture parameter anywhere in the chain β€” so `thread.picture` is null on EVERY create and the parse threw for all of them. WhatsApp creates the newsletter server-side BEFORE the response is parsed, so each call returned 500 while leaving a real channel behind, and `createChannel` is non-idempotent, so a client retrying a 5xx leaked one orphan per attempt (confirmed on the test account). `description` has the same defect whenever the caller omits one. The patch reads every nested field defensively so the response's `id` β€” the only place the new channel's id appears β€” always survives. | exact-shape match; remove once upstream tolerates a pictureless newsletter. |
+| πŸ”§β· | `scripts/patch-wwebjs-participant-arity.js` | whatsapp-web.js `GroupChat.js` | `removeParticipants`/`promoteParticipants`/`demoteParticipants` resolve each requested id against the group's own member collection and drop what they cannot find, then resolve `{status: 200}` for the batch. Dropping EVERY id left the WA Web request builder an empty repeated field, whose arity assertion threw β€” the caller saw an unnamed `500` on removal. Promote and demote have no such assertion, so they answered `200` claiming success for people WhatsApp never touched. The patch keeps the resolved array with its holes, skips the call when nothing resolved, and returns `matched` (one boolean per REQUESTED id) so the adapter can report a per-participant outcome instead of inventing one. | exact-shape match; remove once upstream reports which participants it acted on. |
### 29.3.2 Which matrix rows depend on which patch
-This is the patch visibility the matrix cells refer to. Every patch is engine-specific (4 on wwjs,
+This is the patch visibility the matrix cells refer to. Every patch is engine-specific (5 on wwjs,
1 on Baileys), and **no row carries a row-level patch mark on both engines**. The two column-wide
patches are a separate matter: πŸ”§ΒΉ underwrites every wwjs cell and πŸ”§β΅ every baileys cell, so in
that sense every row does depend on a patch on each side. "Patch-dependent" below means the
@@ -926,7 +927,7 @@ adapter sources β€” re-derive the same way when anything changes:
showed it** β€” `demoteChannelAdmin`'s page function is gone, and `transferChannelOwnership`'s page
function rejects locally against a list it cannot repopulate (both in 29.6.2). Both are Baileys-only
and both are 501 on wwjs. `.d.ts` presence is not capability.
-- **6** install-time patches (4 whatsapp-web.js + 2 Baileys), all exact and self-disabling.
+- **7** install-time patches (5 whatsapp-web.js + 2 Baileys), all exact and self-disabling.
- **0 phantom-support rows** β€” every `not-available` cell throws at the adapter boundary.
- Remaining adapter-gaps (fixable in this repo, ranked): **#1** `getChannelMessages` (Baileys β€”
fetch is one line, `BinaryNode`β†’`ChannelMessage` parser is the work); **#2** `subscribeToChannel`
diff --git a/src/engine/interfaces/whatsapp-engine.interface.ts b/src/engine/interfaces/whatsapp-engine.interface.ts
index e94a1097b..1bce1eaaf 100644
--- a/src/engine/interfaces/whatsapp-engine.interface.ts
+++ b/src/engine/interfaces/whatsapp-engine.interface.ts
@@ -196,10 +196,17 @@ export interface GroupParticipant {
* Outcome of a group membership write (add/remove/promote/demote) for ONE participant. Engines
* that report per-participant results map them verbatim (whatsapp-web.js `addParticipants` resolves
* a `{[participantId]: {code, message}}` object; Baileys `groupParticipantsUpdate` resolves a
- * `[{status, jid}]` array); engines that only confirm the batch as a whole (whatsapp-web.js
- * remove/promote/demote resolve `{status: 200}`) report one success entry per requested participant.
+ * `[{status, jid}]` array).
+ *
+ * whatsapp-web.js remove/promote/demote confirm only the batch, but an install-time patch
+ * (`scripts/patch-wwebjs-participant-arity.js`) makes the page report which requested ids resolved
+ * to actual members, so those entries are per-participant too: an id the page dropped is reported
+ * `404` rather than confirmed. On a tree where that patch was not applied the marker is absent and
+ * the adapter falls back to one batch-confirmed entry per requested participant, which is all the
+ * library reports there.
+ *
* `status` is the engine's own code when it reported one (e.g. 200 ok, 403 invite-only/not-admin,
- * 404 not registered, 409 already a member).
+ * 404 not registered or not a member, 409 already a member).
*/
export interface ParticipantOperationResult {
/** Neutral participant id the outcome belongs to. */