Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
fix(message): say a bad body is a 400 of react and delete
Yudhi Armyndharisb252c24b88f8
diff --git a/docs/06-api-specification.md b/docs/06-api-specification.mdindex ec9677fff..4cb261c72 100644--- a/docs/06-api-specification.md+++ b/docs/06-api-specification.md@@ -2315,7 +2315,7 @@ The controller hardcodes the result after the engine call. Note the `200` status{ "success": true }```-**Errors:** `400` session not active / unknown body field · `401` missing/invalid API key · `403` key role below OPERATOR · `404` message not found in this chat · `500` engine error · `409` conflict or engine not ready (retryable) · `503` the whatsapp-web.js page died mid-request; repeating it is safe (retryable); on Baileys, also when the recipient lookup failed or timed out before the operation was sent (nothing reached WhatsApp, so a retry is safe)+**Errors:** `400` session not active, or an invalid request (an unknown body field or a value of the wrong type) · `401` missing/invalid API key · `403` key role below OPERATOR · `404` message not found in this chat · `500` engine error · `409` conflict or engine not ready (retryable) · `503` the whatsapp-web.js page died mid-request; repeating it is safe (retryable); on Baileys, also when the recipient lookup failed or timed out before the operation was sent (nothing reached WhatsApp, so a retry is safe)#### POST /api/sessions/:sessionId/messages/delete@@ -2349,7 +2349,7 @@ After the engine delete, the stored message's body and `metadata` (inline media,{ "success": true }```-**Errors:** `400` session not active / unknown body field · `401` missing/invalid API key · `403` key role below OPERATOR · `404` message not found in this chat · `500` engine error · `409` conflict or engine not ready (retryable) · `503` session not ready or dependency unavailable (retryable); on Baileys, also when the recipient lookup failed or timed out before the operation was sent (nothing reached WhatsApp, so a retry is safe)+**Errors:** `400` session not active, or an invalid request (an unknown body field or a value of the wrong type) · `401` missing/invalid API key · `403` key role below OPERATOR · `404` message not found in this chat · `500` engine error · `409` conflict or engine not ready (retryable) · `503` session not ready or dependency unavailable (retryable); on Baileys, also when the recipient lookup failed or timed out before the operation was sent (nothing reached WhatsApp, so a retry is safe)#### POST /api/sessions/:sessionId/messages/editdiff --git a/openapi.json b/openapi.jsonindex 789f9b88c..9b8c90a06 100644--- a/openapi.json+++ b/openapi.json@@ -6249,7 +6249,7 @@}},"400": {- "description": "Session not active",+ "description": "Session not active or invalid request","content": {"application/json": {"schema": {@@ -6839,7 +6839,7 @@}},"400": {- "description": "Session not active",+ "description": "Session not active or invalid request","content": {"application/json": {"schema": {diff --git a/src/modules/message/message.controller.spec.ts b/src/modules/message/message.controller.spec.tsindex 1101bd658..67db8c510 100644--- a/src/modules/message/message.controller.spec.ts+++ b/src/modules/message/message.controller.spec.ts@@ -318,14 +318,16 @@ describe('MessageController OpenAPI error responses', () => {});// An unknown message answers 404 (MessageNotFoundError), which these routes declare on its own, so- // their 400 is only the missing live engine. A client reading the 400 as "message not found" would- // never handle the 404 the engine actually raises.+ // their 400 is never "message not found": a client reading it that way would never handle the 404 the+ // engine actually raises. The 400 is the missing live engine, or a body that fails validation (an unknown+ // field, or a value of the wrong type), which is why it also says "invalid request", as send-text does.it.each(['react', 'deleteMessage'])('%s keeps "message not found" out of its 400', method => {const responses = Reflect.getMetadata('swagger/apiResponse',Object.getOwnPropertyDescriptor(MessageController.prototype, method)!.value as object,) as Record<string, { description: string }>;- expect(responses['400'].description).toBe('Session not active');+ expect(responses['400'].description).toBe('Session not active or invalid request');+ expect(responses['400'].description).not.toMatch(/not found/i);expect(Object.keys(responses)).toContain('404');});});diff --git a/src/modules/message/message.controller.ts b/src/modules/message/message.controller.tsindex a17d0fdb0..7f45ded34 100644--- a/src/modules/message/message.controller.ts+++ b/src/modules/message/message.controller.ts@@ -548,7 +548,7 @@ export class MessageController {})@ApiResponse({status: 400,- description: 'Session not active',+ description: 'Session not active or invalid request',})@ApiResponse({ status: 409, description: ENGINE_NOT_READY_409 })@ApiResponse({ status: 404, description: MESSAGE_NOT_FOUND_404 })@@ -784,7 +784,7 @@ export class MessageController {})@ApiResponse({status: 400,- description: 'Session not active',+ description: 'Session not active or invalid request',})@ApiResponse({status: 503,