Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
fix(wwebjs): answer 501 for a call rejection that does not stop the call
Yudhi Armyndharisd21a372ba8a1
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 03e4c8d9d..02a6603be 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -27,6 +27,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0- A failed start in the dashboard that left no engine shows the gateway's error in a toast.- The dashboard closes a session's QR modal when the session fails, or disconnects with no engine left, instead of leaving it spinning.- The dashboard disables a session's Start and Reconnect buttons while its start request is in flight.+- whatsapp-web.js sessions no longer report a call rejection that did not stop the call: the call reject route answers `501` and `autoRejectCalls` logs a failed auto-reject.### Documentation@@ -44,6 +45,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0- Re-export after upgrading for an archive whose stamps are the instants they claim; restoring a pre-release archive carries its shift in as it is.- A WebSocket client can now be disconnected with an `UNAUTHORIZED` frame up to a minute after its key changed, where before only the node that processed the change disconnected it; reconnect and resubscribe on that frame. A rename, and the key's usage counters, evict nobody.- A caller-supplied URL leaves through the session proxy from this release. Set `SESSION_PROXY_URL_FETCH=false` when a session proxy is a WhatsApp-only route that cannot reach arbitrary media hosts.+- whatsapp-web.js: `POST /api/sessions/{sessionId}/calls/{callId}/reject` answers `501` instead of a `200` that did not stop the call from ringing.### Securitydiff --git a/docs/03-system-architecture.md b/docs/03-system-architecture.mdindex f45536cdf..ce2ca3e3d 100644--- a/docs/03-system-architecture.md+++ b/docs/03-system-architecture.md@@ -911,7 +911,7 @@ export interface EngineEventCallbacks {onMessageReaction?: (event: ReactionEvent) => void;onMessageEdited?: (message: EditedMessage) => void;onGroupEvent?: (event: GroupEvent) => void; // kind selects group.join / group.leave / group.update / group.join_request- onCall?: (event: IncomingCallEvent) => void; // incoming call ringing; rejectCall() while it rings+ onCall?: (event: IncomingCallEvent) => void; // incoming call ringing; Baileys can rejectCall() while it ringsonHistoryMessages?: (messages: IncomingMessage[]) => void; // bulk initial sync; persist, don't dispatchonDisconnected?: (reason: string) => void; // recoverable -> reconnectonStateChanged?: (state: EngineStatus) => void;diff --git a/docs/06-api-specification.md b/docs/06-api-specification.mdindex ebc3e8cdf..86632d49a 100644--- a/docs/06-api-specification.md+++ b/docs/06-api-specification.md@@ -6306,7 +6306,7 @@ repeat.Incoming-call management. A `call.received` webhook/socket event (§6.6) announces an incoming ringing call and carries the `callId` used below.-> **Call rejection and the call outcome events are Baileys only, and `call.received` is not reliable on whatsapp-web.js.** Both engines dispatch `call.received`, but on whatsapp-web.js it fired in a live test on 2026-09-17 and did not in one on 2026-08-10. whatsapp-web.js cannot reject a call: a rejection it sent did not stop the call from ringing in a live test, so `autoRejectCalls` has no effect there either. The caller id in `from` may be an `@lid` privacy id on either engine; resolve it with `GET /api/sessions/:sessionId/contacts/:contactId/phone`. `POST .../calls/link` works on both engines.+> **Call rejection and the call outcome events are Baileys only, and `call.received` is not reliable on whatsapp-web.js.** Both engines dispatch `call.received`, but on whatsapp-web.js it fired in a live test on 2026-09-17 and did not in one on 2026-08-10. whatsapp-web.js cannot reject a call: a rejection it sent did not stop the call from ringing in a live test, so the reject route answers `501` there and `autoRejectCalls` logs a failed auto-reject instead. The caller id in `from` may be an `@lid` privacy id on either engine; resolve it with `GET /api/sessions/:sessionId/contacts/:contactId/phone`. `POST .../calls/link` works on both engines.#### POST /api/sessions/:sessionId/calls/link@@ -6348,7 +6348,7 @@ Generate a shareable WhatsApp call link.#### POST /api/sessions/:sessionId/calls/:callId/reject-Reject a currently ringing incoming call. Only a live call can be rejected — the id is valid while the call rings (a short server-side cache); afterwards it expires.+Reject a currently ringing incoming call. **Baileys only**: the whatsapp-web.js engine answers `501`. Only a live call can be rejected — the id is valid while the call rings (a short server-side cache); afterwards it expires.**Auth:** API key (OPERATOR)@@ -6363,7 +6363,7 @@ Reject a currently ringing incoming call. Only a live call can be rejected — t**Response** `200` — `{ "success": true }`-**Errors:** `400` session is not started · `401` missing/invalid `X-API-Key` · `403` key lacks OPERATOR role · `404` call not found or no longer ringing · `409` conflict or engine not ready (retryable) · `503` session not ready or dependency unavailable (retryable)+**Errors:** `400` session is not started · `401` missing/invalid `X-API-Key` · `403` key lacks OPERATOR role · `404` call not found or no longer ringing · `409` conflict or engine not ready (retryable) · `501` the whatsapp-web.js engine cannot reject a call · `503` session not ready or dependency unavailable (retryable)> **Auto-reject per session.** Set `"config": { "autoRejectCalls": true }` when creating a session to have the server reject every incoming call automatically — the `call.received` event is still dispatched first, so automations keep full visibility. Baileys only; see the note at the top of this section.diff --git a/docs/18-sdk-design.md b/docs/18-sdk-design.mdindex 50e8c649a..359edf81a 100644--- a/docs/18-sdk-design.md+++ b/docs/18-sdk-design.md@@ -327,10 +327,10 @@ Media bodies share the `SendMediaRequest` shape: `{ chatId, url? | base64?, mime#### `calls`-| Method | Signature | Description |-| ------------ | ------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- |-| `rejectCall` | `rejectCall(sessionId, callId)` | Reject a ringing incoming call (`callId` comes from the `call.received` event). **Baileys only**: whatsapp-web.js cannot reject a call. **OPERATOR** |-| `createLink` | `createLink(sessionId, body)` | Create a shareable WhatsApp call link (`startTime` is epoch MILLISECONDS). **OPERATOR** |+| Method | Signature | Description |+| ------------ | ------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- |+| `rejectCall` | `rejectCall(sessionId, callId)` | Reject a ringing incoming call (`callId` comes from the `call.received` event). **Baileys only**: whatsapp-web.js answers `501`. **OPERATOR** |+| `createLink` | `createLink(sessionId, body)` | Create a shareable WhatsApp call link (`startTime` is epoch MILLISECONDS). **OPERATOR** |#### `media`@@ -696,10 +696,10 @@ Resources are accessed as properties on the client (e.g. `client.messages`). All#### `client.calls`-| Method | Signature | Description |-| ------------- | --------------------------------------------------- | ---------------------------------------------------------------------------------------------------- |-| `reject_call` | `reject_call(session_id, call_id) -> SuccessResult` | Reject a ringing incoming call. **Baileys only**: whatsapp-web.js cannot reject a call. **OPERATOR** |-| `create_link` | `create_link(session_id, body) -> CallLinkResponse` | Create a shareable WhatsApp call link (`startTime` is epoch MILLISECONDS). **OPERATOR** |+| Method | Signature | Description |+| ------------- | --------------------------------------------------- | --------------------------------------------------------------------------------------------- |+| `reject_call` | `reject_call(session_id, call_id) -> SuccessResult` | Reject a ringing incoming call. **Baileys only**: whatsapp-web.js answers `501`. **OPERATOR** |+| `create_link` | `create_link(session_id, body) -> CallLinkResponse` | Create a shareable WhatsApp call link (`startTime` is epoch MILLISECONDS). **OPERATOR** |#### `client.media`@@ -1040,10 +1040,10 @@ All payloads are associative arrays; all listed methods are synchronous and retu#### `calls`-| Method | Signature | Description |-| ------------ | ------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------- |-| `rejectCall` | `rejectCall(string $sessionId, string $callId): array` | Reject a ringing incoming call (404 when it is not found or no longer ringing). **Baileys only**: whatsapp-web.js cannot reject a call. **OPERATOR** |-| `createLink` | `createLink(string $sessionId, array $body): array` | Create a shareable WhatsApp call link (`startTime` is epoch MILLISECONDS). **OPERATOR** |+| Method | Signature | Description |+| ------------ | ------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------- |+| `rejectCall` | `rejectCall(string $sessionId, string $callId): array` | Reject a ringing incoming call (404 when it is not found or no longer ringing). **Baileys only**: whatsapp-web.js answers `501`. **OPERATOR** |+| `createLink` | `createLink(string $sessionId, array $body): array` | Create a shareable WhatsApp call link (`startTime` is epoch MILLISECONDS). **OPERATOR** |#### `media`diff --git a/docs/29-engine-capability-matrix.md b/docs/29-engine-capability-matrix.mdindex 04b2ce36f..fe858ca2a 100644--- a/docs/29-engine-capability-matrix.md+++ b/docs/29-engine-capability-matrix.md@@ -300,7 +300,7 @@ socket is caught by the transport instead. No REST route: the session watchdog p| Method | Baileys adapter 🔧⁵ | wwjs adapter 🔧¹ | OpenWA REST || -------------------------------- | ------------------- | ---------------- | --------------- |-| `createGroup` | ✅ | ❌ | ✅ |+| `createGroup` | ✅ | ❌ lib | ⚠️ baileys only || `getGroups` | ✅ | ✅ | ✅ || `getGroupInfo` | ✅ | ✅ | ✅ || `addParticipants` | ✅ | ✅ | ✅ |@@ -392,12 +392,12 @@ answers 501.| Method | Baileys adapter 🔧⁵ | wwjs adapter 🔧¹ | OpenWA REST || --------------------- | ------------------- | ---------------- | --------------- || `subscribeToPresence` | ✅ | ❌ lib | ⚠️ baileys only |-| `rejectCall` | ✅ | ✅ | ✅ |+| `rejectCall` | ✅ | ❌ lib | ⚠️ baileys only || `createCallLink` | ✅ | ✅ | ✅ |-**Totals:** 112 methods → 224 adapter cells: **199 ✅, 25 ❌** (2 adapter-gaps, 23-library-limitations, 0 uncertain) across 24 methods. From the REST caller's side: **90** methods-work on any engine (89 fully supported + 2 store-backed status reads), **11** are Baileys-only,+**Totals:** 112 methods → 224 adapter cells: **198 ✅, 26 ❌** (2 adapter-gaps, 24+library-limitations, 0 uncertain) across 25 methods. From the REST caller's side: **89** methods+work on any engine (87 fully supported + 2 store-backed status reads), **13** are Baileys-only,**9** are wwjs-only (the 2 store-backed rows excluded); `sendCatalog`, unavailable on both engines,is not exposed.@@ -774,11 +774,11 @@ with zero OpenWA surface. Baileys-only; whatsapp-web.js has no community API atA row belongs here when both libraries expose a symbol for the same capability and the interfacehas no method for it, because one new interface method then wires both adapters at once.-⚠️ **A symbol in `.d.ts` is not evidence the call works.** `demoteChannelAdmin` and-`transferChannelOwnership` each have a typed `Client` method and a resolvable page module on-whatsapp-web.js, and each fails against live WhatsApp Web — both are `not-available` there and-detailed in 29.6.2. Add a row here from the typings; do not mark its cell `supported` until a live-call has returned WhatsApp's own answer.+⚠️ **A symbol in `.d.ts` is not evidence the call works.** `createGroup`, `demoteChannelAdmin`,+`transferChannelOwnership` and `rejectCall` each have a typed method on whatsapp-web.js (a `Client`+method, or `Call.reject()` for `rejectCall`), and each fails against live WhatsApp Web: all four+are `not-available` there and detailed in 29.6.2. Add a row here from the typings; do not mark its+cell `supported` until a live call has returned WhatsApp's own answer.Near-misses (both libraries have the area, but the symbol sets only partially overlap — stillworth an interface method): **channel admin invites** (wwjs@@ -835,7 +835,7 @@ OpenWA consumes events by normalizing them into `EngineEventCallbacks`; anything| `group_leave` | ✅ | | `group_update` | ✅ || `group_membership_request` | ✅ | | | |-## 29.6 The 25 not-available cells in detail+## 29.6 The 26 not-available cells in detailEvery ❌ in 29.4, with the exact library symbol inspected (full evidence strings:`engine-capability-matrix.ts`). All of these throw `EngineNotSupportedError` → HTTP 501 at the@@ -858,7 +858,7 @@ adapter boundary — none silently stubs.| `sendCatalog` | lib | `AnyMessageContent` (`Types/Message.d.ts:166-210`) has only `{product}` (single product); the catalog CRUD nodes (`Socket/business.js:294-362`) mutate the catalog, they don't send it. || `votePoll` | lib | No vote-send helper at all; the library only _decrypts incoming_ votes (`decryptPollVote`). Sending needs a hand-built `proto.Message.PollUpdateMessage` with HMAC-SHA256 encryption keyed by the poll creation's `messageSecret`. |-### 29.6.2 wwjs adapter (13 cells)+### 29.6.2 wwjs adapter (14 cells)| Method | Cause | What's missing (evidence) || -------------------------- | ----- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |@@ -869,6 +869,7 @@ adapter boundary — none silently stubs.| `upsertLabel` | lib | 1.34.7 reads labels and assigns them (`getLabels`, `getLabelById`, `getChatLabels`, `getChatsByLabelId`, `addOrRemoveLabels`, `index.d.ts:129-154`) but exposes nothing that creates/edits a label definition. || `deleteLabel` | lib | Same as above. || `subscribeToPresence` | lib | Only `sendPresenceAvailable`/`sendPresenceUnavailable` (`index.d.ts:230,233`), which publish the _account's own_ presence; no subscribe call and no presence event is emitted. |+| `rejectCall` | lib | `Call.reject()` exists and is typed `Promise<void>` (`index.d.ts:2417`), but measured live on 2026-09-17 on OpenWA 0.23.4 with WhatsApp Web `2.3000.1047471845-alpha` the reject resolved and OpenWA logged the call as auto-rejected while the caller's phone kept ringing until it timed out. The cause is not established. The page function it runs, `WWebJS.rejectCall`, is modified by OpenWA patch 🔧¹ (`wwebjs-201832`), which reads the own user id from `getMaybeMePnUser()._serialized` or `$1`. Baileys serves this capability, and its auto-reject stopped the caller's phone at once in a live test the same day. || `getCatalog` | lib | No `Client.getCatalog` in `index.d.ts` (0 hits); `Product`/`Order` are inbound-only parsers. || `getProducts` | lib | Same as above. || `getProduct` | lib | Only page-internal `getProductMetadata` (`Utils.js:1290`), not a public Client fn. |@@ -880,13 +881,6 @@ adapter boundary — none silently stubs.✅ means works end-to-end — but these rows carry behavioral differences worth knowing:-- **`rejectCall` (wwjs) is ✅ because the adapter implements it, not because it can succeed.** On- current WhatsApp Web builds whatsapp-web.js 1.34.7 no longer fires its `call` event for a ringing- call: it hooks the internal map of WhatsApp Web's call collection, and real calls no longer pass- through it (measured live on OpenWA 0.14.4 on 2026-08-10, with Baileys firing `call.received` and- `call.rejected` on the same bench). A whatsapp-web.js session therefore emits no `call.*` event,- never learns a `callId` to reject, and ignores the `autoRejectCalls` session setting.- `createCallLink` is unaffected.- **`postTextStatus` / `postImageStatus` / `postVideoStatus` / `postVoiceStatus` (wwjs).**whatsapp-web.js has no status-recipient argument, so `StatusPostOptions.recipients` is **nothonored** — the post broadcasts to the account's status-privacy audience (a one-time warning is@@ -963,15 +957,15 @@ adapter boundary — none silently stubs.Recomputed from `engine-capability-matrix.ts`, `upstream-surface.snapshot.json`, and a scan of theadapter sources — re-derive the same way when anything changes:-- **112** interface methods → **224** adapter cells: **199 ✅** / **25 ❌** (2 adapter-gaps, 23- library-limitations, 0 uncertain), spanning **24** methods.-- Of the 199 ✅ cells, **10 wwjs cells carry an explicit patch dependency** (4 × 🔧² status send,+- **112** interface methods → **224** adapter cells: **198 ✅** / **26 ❌** (2 adapter-gaps, 24+ library-limitations, 0 uncertain), spanning **25** methods.+- Of the 198 ✅ cells, **10 wwjs cells carry an explicit patch dependency** (4 × 🔧² status send,1 × 🔧³ channel link preview, 1 × 🔧⁴ ready-sync, 3 × 🔧⁷ participant arity, 1 × 🔧⁹ groupdescription) and one baileys celldoes (1 × 🔧⁶ newsletter-create parse); the whole wwjs column additionallydepends on 🔧¹, the whole Baileys column on 🔧⁵ — so every row rests on a patch on each side,even though no row carries a row-level mark on both.-- REST caller's view: **90** engine-neutral (88 + 2 store-backed status reads), **12** Baileys-only,+- REST caller's view: **89** engine-neutral (87 + 2 store-backed status reads), **13** Baileys-only,**9** wwjs-only; `sendCatalog` (unavailable on both engines) is not exposed.- Full engine inventory (29.5), split by the exposure legend rather than lumped: Baileys **152**socket methods — 48 wired into interface methods, 5 internal wiring, 29 plumbing, **70 ❌ not@@ -981,11 +975,13 @@ adapter sources — re-derive the same way when anything changes:those 8 settings; 🔩 plumbing is correctly never exposed.- Events: Baileys **34** (15 consumed / 19 dropped), wwjs **31** (16 consumed / 15 dropped).- **0** capabilities in 29.5.3: every capability with first-class symbols on both libraries is- either wired or classified with evidence. Two of them are Baileys-only despite typed- whatsapp-web.js symbols — `demoteChannelAdmin`, whose page function WhatsApp Web no longer- provides, and `transferChannelOwnership`, whose page function rejects locally against a- subscriber list it cannot repopulate (both in 29.6.2). Both answer 501 on wwjs. `.d.ts` presence- is not capability, and only a live call distinguishes the two.+ either wired or classified with evidence. Some are Baileys-only despite typed whatsapp-web.js+ symbols: `createGroup`, whose injected evaluate reaches a page internal without `findImpl`;+ `demoteChannelAdmin`, whose page function WhatsApp Web no longer provides;+ `transferChannelOwnership`, whose page function rejects locally against a subscriber list it+ cannot repopulate; and `rejectCall`, whose `Call.reject()` resolves while the caller's phone+ keeps ringing (all in 29.6.2). Each answers 501 on wwjs. `.d.ts` presence is not capability, and+ only a live call distinguishes the two.- **9** install-time patches (7 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 —diff --git a/openapi.json b/openapi.jsonindex 2cb1d3861..1087f5cd7 100644--- a/openapi.json+++ b/openapi.json@@ -6387,6 +6387,9 @@"409": {"description": "The session is not connected — an engine exists for it but is not `ready`: disconnected, reconnecting, or still initializing, so the request never reached WhatsApp. Wait for `ready` and retry. A session that was never started answers `400` instead, and the session lifecycle routes answer `409` for a conflicting state rather than this. One window answers this while the session still reads `ready`: WhatsApp Web periodically reloads its own page and the engine re-injects into it — for those few seconds the answer is a `409` naming the reload; retry shortly."},+ "501": {+ "description": "The active engine cannot reject a call (whatsapp-web.js)"+ },"503": {"description": "WhatsApp did not answer within the request budget. The change may or may not have been applied — the gateway stopped waiting for a confirmation that never came."}diff --git a/sdk/go/calls.go b/sdk/go/calls.goindex 2b9c69bc8..5fe9f8320 100644--- a/sdk/go/calls.go+++ b/sdk/go/calls.go@@ -33,7 +33,7 @@ func (s *CallsService) base(sessionID string) string {// RejectCall rejects a ringing incoming call; callID comes from the// call.received event (CallReceivedPayload.CallID). A call can only be// rejected while it is still ringing — otherwise the server responds 404.-// Requires an OPERATOR-level key.+// Baileys only; whatsapp-web.js answers 501. Requires an OPERATOR-level key.func (s *CallsService) RejectCall(ctx context.Context, sessionID, callID string) (*SuccessResult, error) {var out SuccessResulterr := s.client.do(ctx, "POST", s.base(sessionID)+"/"+pathEscape(callID)+"/reject", nil, nil, &out)diff --git a/sdk/go/types_webhook.go b/sdk/go/types_webhook.goindex d109fcfdd..e627e1ecb 100644--- a/sdk/go/types_webhook.go+++ b/sdk/go/types_webhook.go@@ -59,8 +59,8 @@ type GroupEventPayload struct {}// CallReceivedPayload is the payload of the call.received event. CallID is the-// handle Calls.RejectCall accepts while the call is still ringing. Timestamp-// is unix seconds.+// handle Calls.RejectCall accepts while the call is still ringing (Baileys+// only; whatsapp-web.js answers 501). Timestamp is unix seconds.type CallReceivedPayload struct {CallID string `json:"callId"`From string `json:"from"`diff --git a/sdk/java/src/main/java/com/rmyndharis/openwa/resources/CallsResource.java b/sdk/java/src/main/java/com/rmyndharis/openwa/resources/CallsResource.javaindex 89d2319c4..e37e95713 100644--- a/sdk/java/src/main/java/com/rmyndharis/openwa/resources/CallsResource.java+++ b/sdk/java/src/main/java/com/rmyndharis/openwa/resources/CallsResource.java@@ -17,8 +17,9 @@ public final class CallsResource {}/**- * Reject a ringing incoming call. The {@code callId} comes from a {@code call.received}- * webhook event; 404 when the call is not found or no longer ringing.+ * Reject a ringing incoming call. Baileys only; whatsapp-web.js answers {@code 501}. The+ * {@code callId} comes from a {@code call.received} webhook event; 404 when the call is not+ * found or no longer ringing.*/public SuccessResult rejectCall(String sessionId, String callId) {return client.request(diff --git a/sdk/javascript/src/resources/calls.ts b/sdk/javascript/src/resources/calls.tsindex 2e56b75d6..e4a4d543a 100644--- a/sdk/javascript/src/resources/calls.ts+++ b/sdk/javascript/src/resources/calls.ts@@ -13,9 +13,10 @@ export class CallsResource {constructor(private readonly client: OpenWAClient) {}/**- * Reject a ringing incoming call. The `callId` comes from the `call.received`- * webhook/socket event; the server answers 404 when the call is not found or no- * longer ringing. Requires an OPERATOR-level key.+ * Reject a ringing incoming call. **Baileys only**: whatsapp-web.js answers 501.+ * The `callId` comes from the `call.received` webhook/socket event; the server+ * answers 404 when the call is not found or no longer ringing. Requires an+ * OPERATOR-level key.*/rejectCall(sessionId: string, callId: string): Promise<SuccessResult> {return this.client.request<SuccessResult>({diff --git a/sdk/php/src/Resources/CallsResource.php b/sdk/php/src/Resources/CallsResource.phpindex 1b6acd524..a170c556a 100644--- a/sdk/php/src/Resources/CallsResource.php+++ b/sdk/php/src/Resources/CallsResource.php@@ -22,8 +22,8 @@ class CallsResource/*** Reject a ringing incoming call (the callId from the call.received event).- * 404 when the call is not found or no longer ringing. Requires an- * OPERATOR-level key.+ * Baileys only; whatsapp-web.js answers 501. 404 when the call is not found+ * or no longer ringing. Requires an OPERATOR-level key.** @return array<string,mixed>*/diff --git a/sdk/python/openwa/resources/calls.py b/sdk/python/openwa/resources/calls.pyindex 572614e5d..7903c4317 100644--- a/sdk/python/openwa/resources/calls.py+++ b/sdk/python/openwa/resources/calls.py@@ -21,7 +21,8 @@ class CallsResource:def reject_call(self, session_id: str, call_id: str) -> SuccessResult:"""Reject a ringing incoming call (the id comes from the ``call.received`` event).- Requires an OPERATOR-level key. 404 when the call is not found or no longer ringing.+ Baileys only; whatsapp-web.js answers 501. Requires an OPERATOR-level key. 404 when the call+ is not found or no longer ringing."""return self._http.request("POST", f"/api/sessions/{quote_segment(session_id)}/calls/{quote_segment(call_id)}/reject"diff --git a/src/engine/adapters/whatsapp-web-js.adapter.spec.ts b/src/engine/adapters/whatsapp-web-js.adapter.spec.tsindex 374462f60..6c38e37b7 100644--- a/src/engine/adapters/whatsapp-web-js.adapter.spec.ts+++ b/src/engine/adapters/whatsapp-web-js.adapter.spec.ts@@ -30,7 +30,6 @@ import { ChannelMediaNotSupportedError } from '../../common/errors/channel-mediaimport { EngineNotSupportedError } from '../../common/errors/engine-not-supported.error';import { RecipientUnreachableError } from '../../common/errors/recipient-unreachable.error';import { EditedMessage, EngineStatus, GroupEvent, IncomingCallEvent } from '../interfaces/whatsapp-engine.interface';-import { CallNotFoundError } from '../../common/errors/call-not-found.error';import { EngineRefusedError } from '../../common/errors/engine-refused.error';import { EngineTransportError } from '../../common/errors/engine-transport.error';import { InvalidInviteCodeError } from '../../common/errors/invalid-invite-code.error';@@ -3723,45 +3722,35 @@ describe('WhatsAppWebJsAdapter call event + rejectCall', () => {expect(onCall).toHaveBeenCalledTimes(2);});- it('a deduplicated repeat does not evict the live call', async () => {- const { adapter, client } = wireCallHandler();- const call = liveCall();-- client.emit('call', call);- client.emit('call', call);-- await expect(adapter.rejectCall('CALL1')).resolves.toBeUndefined();- expect(call.reject).toHaveBeenCalledTimes(1);- });-// Discriminating on the REFRESH specifically: the second signal lands 90s in, so the entry is// only expired at 150s if its expiry was never extended. LIVE_CALL_TTL_MS is 120s.- it('a repeat extends the rejectable window from the latest signal, not the first', async () => {+ it('a repeat keeps the call cached from the latest signal, so it is not announced again', () => {jest.useFakeTimers();try {- const { adapter, client } = wireCallHandler();- const call = liveCall();+ const { onCall, client } = wireCallHandler();- client.emit('call', call);+ client.emit('call', liveCall());jest.advanceTimersByTime(90_000);- client.emit('call', call);+ client.emit('call', liveCall());jest.advanceTimersByTime(60_000); // 150s after the first signal, 60s after the second+ client.emit('call', liveCall());- await expect(adapter.rejectCall('CALL1')).resolves.toBeUndefined();+ expect(onCall).toHaveBeenCalledTimes(1);} finally {jest.useRealTimers();}});- it('a call still expires when no repeat arrives', async () => {+ it('announces the same call id again once its entry expired with no repeat', () => {jest.useFakeTimers();try {- const { adapter, client } = wireCallHandler();+ const { onCall, client } = wireCallHandler();client.emit('call', liveCall());jest.advanceTimersByTime(150_000);+ client.emit('call', liveCall());- await expect(adapter.rejectCall('CALL1')).rejects.toBeInstanceOf(CallNotFoundError);+ expect(onCall).toHaveBeenCalledTimes(2);} finally {jest.useRealTimers();}@@ -3769,13 +3758,15 @@ describe('WhatsAppWebJsAdapter call event + rejectCall', () => {it.each([{ id: '' }, { id: undefined }, { from: '' }, { from: undefined }, null])('drops a malformed call (%o) — nothing emitted, nothing cached',- async malformed => {- const { adapter, onCall, client } = wireCallHandler();+ malformed => {+ const { onCall, client } = wireCallHandler();client.emit('call', malformed === null ? null : liveCall(malformed as Record<string, unknown>));-expect(onCall).not.toHaveBeenCalled();- await expect(adapter.rejectCall('CALL1')).rejects.toBeInstanceOf(CallNotFoundError);++ // Nothing cached: a well-formed call with the same id is still announced.+ client.emit('call', liveCall());+ expect(onCall).toHaveBeenCalledTimes(1);},);@@ -3788,44 +3779,29 @@ describe('WhatsAppWebJsAdapter call event + rejectCall', () => {expect(onCall).not.toHaveBeenCalled();});- it('rejectCall rejects the cached live call and evicts it (second reject -> not found)', async () => {+ // A whatsapp-web.js rejection resolved while the caller's phone kept ringing, so the adapter refuses,+ // even for a ringing call, instead of reporting a rejection that did not stop the call.+ it('rejectCall answers EngineNotSupportedError and never calls Call.reject()', async () => {const { adapter, client } = wireCallHandler();const call = liveCall();client.emit('call', call);- await adapter.rejectCall('CALL1');-- expect(call.reject).toHaveBeenCalledTimes(1);- await expect(adapter.rejectCall('CALL1')).rejects.toBeInstanceOf(CallNotFoundError);- });-- it('rejectCall on an unknown id throws CallNotFoundError (HTTP 404)', async () => {- const { adapter } = wireCallHandler();-- await expect(adapter.rejectCall('NOPE')).rejects.toBeInstanceOf(CallNotFoundError);- });-- it('rejectCall on an expired entry throws CallNotFoundError without touching the call', async () => {- const { adapter, client } = wireCallHandler();- const call = liveCall();- client.emit('call', call);- // Age the cached entry past the TTL (calls ring ~a minute; the handle dies with the call).- const cache = (adapter as unknown as { liveCalls: Map<string, { expiresAt: number }> }).liveCalls;- cache.get('CALL1')!.expiresAt = Date.now() - 1;+ const err: unknown = await adapter.rejectCall('CALL1').catch((e: unknown) => e);- await expect(adapter.rejectCall('CALL1')).rejects.toBeInstanceOf(CallNotFoundError);+ expect(err).toBeInstanceOf(EngineNotSupportedError);+ expect((err as EngineNotSupportedError).getStatus()).toBe(501);expect(call.reject).not.toHaveBeenCalled();});- it('teardown clears the live-call cache (reject after disconnect -> not found)', async () => {+ it('teardown clears the ringing call cache', async () => {const { adapter, client } = wireCallHandler();- const call = liveCall();- client.emit('call', call);+ client.emit('call', liveCall());+ const cache = (adapter as unknown as { liveCalls: Map<string, number> }).liveCalls;+ expect(cache.has('CALL1')).toBe(true);await adapter.disconnect();- await expect(adapter.rejectCall('CALL1')).rejects.toBeInstanceOf(CallNotFoundError);- expect(call.reject).not.toHaveBeenCalled();+ expect(cache.size).toBe(0);});it('logs and drops a malformed call instead of throwing into the client emitter', () => {diff --git a/src/engine/adapters/whatsapp-web-js.adapter.ts b/src/engine/adapters/whatsapp-web-js.adapter.tsindex 8442ffdb3..1bc8777db 100644--- a/src/engine/adapters/whatsapp-web-js.adapter.ts+++ b/src/engine/adapters/whatsapp-web-js.adapter.ts@@ -1,5 +1,5 @@import { EventEmitter } from 'events';-import { MessageMedia, type Call, type Client, type Message } from 'whatsapp-web.js';+import { MessageMedia, type Client, type Message } from 'whatsapp-web.js';import {CallLinkType,IWhatsAppEngine,@@ -191,11 +191,10 @@ export class WhatsAppWebJsAdapter extends EventEmitter implements IWhatsAppEnginprivate set disconnectReported(value: boolean) {this.lifecycle.disconnectReported = value;}- /** Live incoming calls by call id — the map is owned by the calls delegate (call events +- * rejectCall); lifecycle teardown clears it so a late rejectCall() reports not-found on a dead- * client. The adapter keeps this alias for the unmodified spec, which reads `adapter.liveCalls`- * through a cast. */- private get liveCalls(): Map<string, { call: Call; expiresAt: number }> {+ /** Ringing call ids and their expiry, owned by the calls delegate, which uses them to announce each+ * call once; lifecycle teardown clears them. The adapter keeps this alias for the spec, which reads+ * `adapter.liveCalls` through a cast. */+ private get liveCalls(): Map<string, number> {return this.calls.liveCalls;}@@ -536,8 +535,8 @@ export class WhatsAppWebJsAdapter extends EventEmitter implements IWhatsAppEnginreturn this.profile.createCallLink(type, startTime);}- /** See ./wwebjs-calls — the entry is evicted on ANY attempt; an unknown or expired id maps to- * CallNotFoundError (HTTP 404). */+ /** Always EngineNotSupportedError (HTTP 501): a rejection did not stop a live call ringing. See+ * ./wwebjs-calls. */async rejectCall(callId: string): Promise<void> {return this.calls.rejectCall(callId);}diff --git a/src/engine/adapters/wwebjs-calls.ts b/src/engine/adapters/wwebjs-calls.tsindex b2d6648bc..7a79d9f2d 100644--- a/src/engine/adapters/wwebjs-calls.ts+++ b/src/engine/adapters/wwebjs-calls.ts@@ -1,13 +1,13 @@import { type Call } from 'whatsapp-web.js';import { type EngineEventCallbacks, type IncomingCallEvent } from '../interfaces/whatsapp-engine.interface';import { type createLogger } from '../../common/services/logger.service';-import { CallNotFoundError } from '../../common/errors/call-not-found.error';+import { EngineNotSupportedError } from '../../common/errors/engine-not-supported.error';/**- * Incoming-call handling extracted from WhatsAppWebJsAdapter: the `call` client event, the live-call- * cache a later rejectCall() acts on, and that rejection. The adapter keeps the public methods as- * thin forwarders and injects the host surface via closures, so the delegate never touches lifecycle- * state directly.+ * Incoming-call handling extracted from WhatsAppWebJsAdapter: the `call` client event, the cache of+ * ringing call ids that keeps one call from surfacing as several events, and the call rejection this+ * engine refuses. The adapter keeps the public methods as thin forwarders and injects the host+ * surface via closures, so the delegate never touches lifecycle state directly.*/export interface WwebjsCallsHost {readonly logger: ReturnType<typeof createLogger>;@@ -18,30 +18,28 @@ export interface WwebjsCallsHost {}export class WwebjsCalls {- /** How long a received call's handle stays rejectable. Calls ring for roughly a minute, so- * two minutes covers the ringing window with margin without pinning dead calls for long. */+ /** How long a received call id stays cached. Calls ring for roughly a minute, so two minutes+ * covers the ringing window with margin without pinning dead calls for long. */private static readonly LIVE_CALL_TTL_MS = 2 * 60_000;- /** Live incoming calls by call id. The wwebjs `Call` object is only usable while the call is- * live, so it must be cached at event time for a later rejectCall() to act on. Public so the- * adapter's `liveCalls` alias keeps working (an unmodified spec reads `adapter.liveCalls`- * through a cast) and lifecycle teardown can clear it when the client goes away. */- readonly liveCalls = new Map<string, { call: Call; expiresAt: number }>();+ /** Expiry time of each ringing call, by call id. Public so the adapter's `liveCalls` alias keeps+ * working (the spec reads `adapter.liveCalls` through a cast) and lifecycle teardown can clear it+ * when the client goes away. */+ readonly liveCalls = new Map<string, number>();constructor(private readonly host: WwebjsCallsHost) {}/**- * Map a whatsapp-web.js `Call` (client `call` event) to the neutral IncomingCallEvent and cache- * the live Call so rejectCall() can act on it later — the Call object is only usable while the- * call is live. Own-account calls (fromMe) are skipped: they are outgoing, not incoming. wwebjs- * ids are already neutral (@c.us), so no jid translation is needed. The try/catch mirrors- * message_edit: a malformed call is logged and dropped, never thrown back into the emitter.+ * Map a whatsapp-web.js `Call` (client `call` event) to the neutral IncomingCallEvent. Own-account+ * calls (fromMe) are skipped: they are outgoing, not incoming. `from` is passed through as the+ * library reports it, and that can be an `@lid` privacy id rather than `@c.us`. The try/catch+ * mirrors message_edit: a malformed call is logged and dropped, never thrown back into the emitter.*/handleIncomingCall(call: Call): void {try {// Symmetry with the other client-event handlers (qr/authenticated): a call landing during or- // after teardown is dropped. A malformed call without the id/from rejectCall() later depends- // on is dropped too — never cached, never emitted.+ // after teardown is dropped. A malformed call without an id or a caller is dropped too: never+ // cached, never emitted.if (this.host.isTearingDown() || !call?.id || !call.from) {return;}@@ -49,10 +47,10 @@ export class WwebjsCalls {return;}// whatsapp-web.js fires this handler from a patched `internalCallMap.set()`, which runs on- // every write to that map — including updates to a call already ringing — so the same call id+ // every write to that map, including updates to a call already ringing, so the same call id// can arrive more than once. Cache first and emit only for an id not already live, otherwise// one call surfaces as several `call.received` events.- if (!this.cacheLiveCall(call.id, call)) {+ if (!this.cacheLiveCall(call.id)) {return;}const payload: IncomingCallEvent = {@@ -72,43 +70,46 @@ export class WwebjsCalls {}/**- * Cache a live call for a later rejectCall(). Lazy expiry: inserting a new call drops- * already-expired entries, so a session that receives calls but never rejects them can't grow- * the map without bound; an entry that never sees another call is tiny and is dropped on+ * Cache a ringing call id. Lazy expiry: inserting a new call drops already-expired entries, so the+ * map cannot grow without bound; an entry that never sees another call is tiny and is dropped on* teardown or at the next call. No per-entry timer to clean up.** Returns true when `callId` was not already ringing, which is what makes `call.received` fire- * once per call rather than once per upstream map write. A repeat write still refreshes the- * entry, so a long-ringing call stays rejectable for a full TTL from the most recent signal.+ * once per call rather than once per upstream map write. A repeat write refreshes the entry, so a+ * long-ringing call is not announced a second time.*/- private cacheLiveCall(callId: string, call: Call): boolean {+ private cacheLiveCall(callId: string): boolean {const now = Date.now();- for (const [id, entry] of this.liveCalls) {- if (entry.expiresAt <= now) {+ for (const [id, expiresAt] of this.liveCalls) {+ if (expiresAt <= now) {this.liveCalls.delete(id);}}const isNewCall = !this.liveCalls.has(callId);- this.liveCalls.set(callId, { call, expiresAt: now + WwebjsCalls.LIVE_CALL_TTL_MS });+ this.liveCalls.set(callId, now + WwebjsCalls.LIVE_CALL_TTL_MS);return isNewCall;}/**- * Reject a currently-ringing call. The entry is evicted on ANY attempt (a rejected/ended call- * will not become rejectable again); an unknown id or an expired entry maps to CallNotFoundError- * (HTTP 404). A failure of the library's reject() itself propagates as-is.+ * Not available on this engine, despite `Call.reject()` existing and being typed `Promise<void>`+ * (`index.d.ts:2417`).+ *+ * Measured live on 2026-09-17 on OpenWA 0.23.4 with WhatsApp Web `2.3000.1047471845-alpha`: the+ * reject resolved and OpenWA logged the call as auto-rejected, but the caller's phone kept ringing+ * until it timed out, while a Baileys auto-reject stopped the caller's phone at once that day. Why+ * the rejection has no effect is not established. The page function it runs, `WWebJS.rejectCall`,+ * is modified by OpenWA's install-time patch (`scripts/wwebjs-201832.patch`), which reads the own+ * user id as `getMaybeMePnUser()._serialized || $1`.+ *+ * A 501 tells the caller the truth where a 200 claimed a rejection that did not stop the call.+ * Restoring support needs a live call proving that a rejection stops the ringing.*/- async rejectCall(callId: string): Promise<void> {- const entry = this.liveCalls.get(callId);- this.liveCalls.delete(callId);- if (!entry || entry.expiresAt <= Date.now()) {- throw new CallNotFoundError(callId);- }- await entry.call.reject();+ /* eslint-disable-next-line @typescript-eslint/require-await, @typescript-eslint/no-unused-vars */+ async rejectCall(_callId: string): Promise<void> {+ throw new EngineNotSupportedError('rejectCall');}- /** Drop every cached call handle — called when the client goes away, so a later rejectCall()- * reports not-found instead of acting on a destroyed page. */+ /** Drop every cached call id when the client goes away: the ids belong to the client that saw them. */clearLiveCalls(): void {this.liveCalls.clear();}diff --git a/src/engine/adapters/wwebjs-lifecycle.ts b/src/engine/adapters/wwebjs-lifecycle.tsindex b6f83143a..f5cea6c14 100644--- a/src/engine/adapters/wwebjs-lifecycle.ts+++ b/src/engine/adapters/wwebjs-lifecycle.ts@@ -122,7 +122,7 @@ export interface WwebjsLifecycleHost {/** Arm / disarm the onboarding-modal watcher (./wwebjs-onboarding). */startOnboardingWatcher(): void;clearOnboardingWatcher(): void;- /** Drop every cached live-call handle — the client they point at is going away. */+ /** Drop every cached ringing call id: the client that saw those calls is going away. */clearLiveCalls(): void;/** Stand-in promise for the LocalAuth profile removal (./wwebjs-stuck-auth), routed through the* adapter's own method so an instance-level replacement stays authoritative. */@@ -706,8 +706,8 @@ export class WwebjsLifecycle {isPageTransportError(error: unknown): boolean {// An HttpException is never a dead page. It is an error THIS application constructed, and its// message carries caller-supplied text verbatim: MessageNotFoundError reads- // `Message ${messageId} not found in chat ${chatId}`, and GroupNotFoundError, LabelNotFoundError,- // ChannelNotFoundError and CallNotFoundError have the same shape. Matching the pattern against+ // `Message ${messageId} not found in chat ${chatId}`, and GroupNotFoundError, LabelNotFoundError+ // and ChannelNotFoundError have the same shape. Matching the pattern against// one of those hands the CALLER the classifier. A request naming a messageId of "Target closed"// made its own 404 read as a transport death: the session was torn down and reconnected, and the// caller got a 503. The reactions read needs no role at all, so the lowest-privilege key could@@ -812,8 +812,7 @@ export class WwebjsLifecycle {private beginClientTeardown(): Client | null {this.tearingDown = true;- // Any cached call handle is dead once the client goes away — drop them all so a later- // rejectCall() reports not-found instead of acting on a destroyed page.+ // The cached ringing call ids belong to the client that is going away, so drop them all.this.host.clearLiveCalls();// Before the clientless early-return: a teardown must always close the navigation window, or a// stale stamp could grace the next generation's probe (single-use contract notwithstanding).diff --git a/src/engine/engine-capability-matrix.ts b/src/engine/engine-capability-matrix.tsindex 245597a5a..0f3ada0ed 100644--- a/src/engine/engine-capability-matrix.ts+++ b/src/engine/engine-capability-matrix.ts@@ -299,10 +299,10 @@ export const CURATED_CAPABILITY_EXCEPTIONS: Record<string, MethodCapability> = {'baileys createCallLink(type, {startTime}, timeoutMs) (Socket/chats.d.ts:17) resolves the bare link_create token (Socket/chats.js:586-603), assembled behind CALL_VIDEO_PREFIX / CALL_AUDIO_PREFIX (Defaults/index.d.ts:5-6); wwjs Client.createCallLink(startTime, callType) (index.d.ts:342) resolves the finished link or an empty string (Client.js:3212-3235)',},rejectCall: {- wwjs: { status: 'supported' },+ wwjs: { status: 'not-available', rootCause: 'library-limitation' },baileys: { status: 'supported' },evidence:- "wwjs Call.reject() (index.d.ts:2417) on the live Call cached from the client 'call' event (index.d.ts:643); baileys rejectCall(callId, callFrom) (Socket/messages-recv.d.ts:10) with the raw `from` JID cached from the 'offer' call event (Types/Call.d.ts). On current WhatsApp Web builds the wwjs 'call' event no longer fires for a ringing call (measured live on OpenWA 0.14.4 on 2026-08-10, Baileys firing call.received and call.rejected on the same bench), so the wwjs cache is never populated: the cell records the implemented method, and docs/29 29.7 carries the caveat",+ "baileys rejectCall(callId, callFrom) (Socket/messages-recv.d.ts:10) with the raw `from` JID cached from the 'offer' call event (Types/Call.d.ts); measured live on 2026-09-17 with 7.0.0-rc14, a real call fired call.received then call.rejected and auto-reject stopped the caller's phone at once. wwjs Call.reject() exists and is typed Promise<void> (index.d.ts:2417) on the Call from the client 'call' event (index.d.ts:643), but measured live on 2026-09-17 on OpenWA 0.23.4 with WhatsApp Web 2.3000.1047471845-alpha the reject resolved and OpenWA logged the call as auto-rejected while the caller's phone kept ringing until it timed out. The cause is not established. The page function Call.reject() runs, WWebJS.rejectCall, is modified by OpenWA patch 1 (scripts/wwebjs-201832.patch), which reads getMaybeMePnUser()._serialized || $1",},sendCatalog: {wwjs: { status: 'not-available', rootCause: 'library-limitation' },diff --git a/src/engine/interfaces/whatsapp-engine.interface.ts b/src/engine/interfaces/whatsapp-engine.interface.tsindex 6cd6b39d5..a26df23ba 100644--- a/src/engine/interfaces/whatsapp-engine.interface.ts+++ b/src/engine/interfaces/whatsapp-engine.interface.ts@@ -642,15 +642,15 @@ export interface GroupEvent {/*** An incoming (ringing) call, mapped at the adapter boundary to this neutral shape:- * - whatsapp-web.js: the client `call` event (a `Call` object the adapter caches so a later- * `rejectCall` can act on it — the object is only usable while the call is live).+ * - whatsapp-web.js: the client `call` event (the adapter caches the ringing call id so a repeated+ * signal for the same call is not announced twice).* - Baileys: the `call` event's `offer` status entries (other statuses are lifecycle updates and* are not surfaced).* All ids are in the neutral dialect (`@c.us`; a lid caller stays `<id>@lid` when the lid->phone* mapping is unknown, resolved via the inline phone twin when the engine provides one).*/export interface IncomingCallEvent {- /** Engine call id; the handle `rejectCall` accepts while the call is still ringing. */+ /** Engine call id; the id `rejectCall` accepts while the call is still ringing (Baileys). */callId: string;/** Neutral caller id. */from: string;@@ -773,9 +773,9 @@ export interface EngineEventCallbacks {*/onGroupEvent?: (event: GroupEvent) => void;/**- * Fired when an incoming call starts ringing (consumers emit `call.received`). The call can be- * rejected via `rejectCall(callId)` only while it is still ringing — the adapter keeps the- * engine's live call handle cached for that window.+ * Fired when an incoming call starts ringing (consumers emit `call.received`). On Baileys the call+ * can be rejected via `rejectCall(callId)` only while it is still ringing: the adapter keeps what+ * the rejection needs cached for that window. whatsapp-web.js refuses `rejectCall`.*/onCall?: (event: IncomingCallEvent) => void;/**@@ -1208,9 +1208,10 @@ export interface GroupCapability {*/export interface CallCapability {/**- * Reject an incoming call. Only a currently-ringing call can be rejected: the adapter keeps the- * engine's live call handle (keyed by the `callId` from {@link IncomingCallEvent}) for the- * ringing window, and an unknown or expired callId fails with a not-found error (HTTP 404).+ * Reject an incoming call. Only a currently-ringing call can be rejected: the Baileys adapter keeps+ * the caller JID it needs (keyed by the `callId` from {@link IncomingCallEvent}) for the ringing+ * window, and an unknown or expired callId fails with a not-found error (HTTP 404). whatsapp-web.js+ * throws EngineNotSupportedError (HTTP 501): a rejection it sent did not stop a live call ringing.*/rejectCall(callId: string): Promise<void>;diff --git a/src/modules/call/call.controller.ts b/src/modules/call/call.controller.tsindex 9abc6a507..e3050e995 100644--- a/src/modules/call/call.controller.ts+++ b/src/modules/call/call.controller.ts@@ -39,6 +39,7 @@ export class CallController {@ApiResponse({ status: 200, description: 'Call rejected', type: CallAckResponseDto })@ApiResponse({ status: 400, description: 'Session is not started' })@ApiResponse({ status: 404, description: 'Call not found or no longer ringing' })+ @ApiResponse({ status: 501, description: 'The active engine cannot reject a call (whatsapp-web.js)' })@ApiResponse({status: 503,description:diff --git a/src/modules/call/call.service.ts b/src/modules/call/call.service.tsindex 117766e3b..9120632ed 100644--- a/src/modules/call/call.service.ts+++ b/src/modules/call/call.service.ts@@ -18,8 +18,8 @@ export class CallService {/*** Reject a currently-ringing incoming call. An unknown or no-longer-ringing callId surfaces- * as 404 via the adapter's CallNotFoundError; EngineNotSupportedError would map to 501 (both- * engines support rejectCall today, so no special-casing here).+ * as 404 via the Baileys adapter's CallNotFoundError; the whatsapp-web.js adapter throws+ * EngineNotSupportedError, which maps to 501, so no special-casing here.*/rejectCall(sessionId: string, callId: string): Promise<void> {return this.getEngine(sessionId).rejectCall(callId);diff --git a/src/modules/session/session-engine-leaf-events.ts b/src/modules/session/session-engine-leaf-events.tsindex 291d8299e..f6b43a0de 100644--- a/src/modules/session/session-engine-leaf-events.ts+++ b/src/modules/session/session-engine-leaf-events.ts@@ -202,6 +202,7 @@ export class SessionEngineLeafEvents {sessionId: id,callId,error: err instanceof Error ? err.message : String(err),+ action: 'call_auto_reject_failed',});}}diff --git a/src/modules/session/session.service.spec.ts b/src/modules/session/session.service.spec.tsindex 41b17aac7..816f822eb 100644--- a/src/modules/session/session.service.spec.ts+++ b/src/modules/session/session.service.spec.ts@@ -14,6 +14,7 @@ import {HttpStatus,} from '@nestjs/common';import { EngineTransportError } from '../../common/errors/engine-transport.error';+import { EngineNotSupportedError } from '../../common/errors/engine-not-supported.error';import { ConfigService } from '@nestjs/config';import { SessionService, AUTOSTART_THROTTLE_MS } from './session.service';import { SessionOwnershipService } from './session-ownership.service';@@ -6983,6 +6984,32 @@ describe('SessionService', () => {expect(eventsGateway.emitCallReceived).toHaveBeenCalledTimes(1);});+ // whatsapp-web.js refuses rejectCall because a rejection it sent did not stop the call ringing.+ // The log must say the auto-reject failed, never that the call was rejected.+ it('an engine that refuses rejectCall logs the failed auto-reject warn, not Auto-rejected, and still dispatches call.received', async () => {+ const onCall = await startAndCaptureCallCallback({ autoRejectCalls: true });+ mockEngine.rejectCall.mockRejectedValue(new EngineNotSupportedError('rejectCall'));+ const logger = (lifecycle as unknown as { logger: { log: () => void; warn: () => void } }).logger;+ const log = jest.spyOn(logger, 'log');+ const warn = jest.spyOn(logger, 'warn');++ try {+ onCall(callEvent());+ await flush();++ expect(warn).toHaveBeenCalledWith(+ 'Failed to auto-reject incoming call',+ expect.objectContaining({ sessionId: 'sess-uuid-1', callId: 'CALL1', action: 'call_auto_reject_failed' }),+ );+ expect(log).not.toHaveBeenCalledWith('Auto-rejected incoming call', expect.anything());+ expect(webhookService.dispatch).toHaveBeenCalledWith('sess-uuid-1', 'call.received', expect.anything());+ expect(eventsGateway.emitCallReceived).toHaveBeenCalledTimes(1);+ } finally {+ log.mockRestore();+ warn.mockRestore();+ }+ });+it('drops the event when it arrives from a stale (superseded) engine', async () => {const onCall = await startAndCaptureCallCallback({ autoRejectCalls: true });// A newer engine now owns the id (restart/reconnect window): the captured callback is stale.