Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

fix(openapi): describe the 404 of a quoted send on its own terms

Yudhi Armyndharisfe4ce7287fa0
diff --git a/openapi.json b/openapi.json
index f8e30f029..2fc5dbf8d 100644
--- a/openapi.json
+++ b/openapi.json
@@ -4484,7 +4484,7 @@
}
},
"404": {
- "description": "No such message: the id is outside the engine's lookup window (roughly the last hundred messages of the chat, or absent from the Baileys store) or the message was revoked.",
+ "description": "The `quotedMessageId` could not be resolved: the whatsapp-web.js page does not hold it, or the Baileys store does not (it was never received or sent by this session, or it was evicted or deleted). On whatsapp-web.js a message that resolves but cannot be replied to is sent without the quote.",
"content": {
"application/json": {
"schema": {
@@ -4746,7 +4746,7 @@
}
},
"404": {
- "description": "No such message: the id is outside the engine's lookup window (roughly the last hundred messages of the chat, or absent from the Baileys store) or the message was revoked.",
+ "description": "The `quotedMessageId` could not be resolved: the whatsapp-web.js page does not hold it, or the Baileys store does not (it was never received or sent by this session, or it was evicted or deleted). On whatsapp-web.js a message that resolves but cannot be replied to is sent without the quote.",
"content": {
"application/json": {
"schema": {
@@ -4896,7 +4896,7 @@
}
},
"404": {
- "description": "No such message: the id is outside the engine's lookup window (roughly the last hundred messages of the chat, or absent from the Baileys store) or the message was revoked.",
+ "description": "The `quotedMessageId` could not be resolved: the whatsapp-web.js page does not hold it, or the Baileys store does not (it was never received or sent by this session, or it was evicted or deleted). On whatsapp-web.js a message that resolves but cannot be replied to is sent without the quote.",
"content": {
"application/json": {
"schema": {
@@ -5047,7 +5047,7 @@
}
},
"404": {
- "description": "No such message: the id is outside the engine's lookup window (roughly the last hundred messages of the chat, or absent from the Baileys store) or the message was revoked.",
+ "description": "The `quotedMessageId` could not be resolved: the whatsapp-web.js page does not hold it, or the Baileys store does not (it was never received or sent by this session, or it was evicted or deleted). On whatsapp-web.js a message that resolves but cannot be replied to is sent without the quote.",
"content": {
"application/json": {
"schema": {
@@ -5198,7 +5198,7 @@
}
},
"404": {
- "description": "No such message: the id is outside the engine's lookup window (roughly the last hundred messages of the chat, or absent from the Baileys store) or the message was revoked.",
+ "description": "The `quotedMessageId` could not be resolved: the whatsapp-web.js page does not hold it, or the Baileys store does not (it was never received or sent by this session, or it was evicted or deleted). On whatsapp-web.js a message that resolves but cannot be replied to is sent without the quote.",
"content": {
"application/json": {
"schema": {
@@ -5350,7 +5350,7 @@
}
},
"404": {
- "description": "No such message: the id is outside the engine's lookup window (roughly the last hundred messages of the chat, or absent from the Baileys store) or the message was revoked.",
+ "description": "The `quotedMessageId` could not be resolved: the whatsapp-web.js page does not hold it, or the Baileys store does not (it was never received or sent by this session, or it was evicted or deleted). On whatsapp-web.js a message that resolves but cannot be replied to is sent without the quote.",
"content": {
"application/json": {
"schema": {
@@ -5491,7 +5491,7 @@
}
},
"404": {
- "description": "No such message: the id is outside the engine's lookup window (roughly the last hundred messages of the chat, or absent from the Baileys store) or the message was revoked.",
+ "description": "The `quotedMessageId` could not be resolved: the whatsapp-web.js page does not hold it, or the Baileys store does not (it was never received or sent by this session, or it was evicted or deleted). On whatsapp-web.js a message that resolves but cannot be replied to is sent without the quote.",
"content": {
"application/json": {
"schema": {
@@ -5631,7 +5631,7 @@
}
},
"404": {
- "description": "No such message: the id is outside the engine's lookup window (roughly the last hundred messages of the chat, or absent from the Baileys store) or the message was revoked.",
+ "description": "The `quotedMessageId` could not be resolved: the whatsapp-web.js page does not hold it, or the Baileys store does not (it was never received or sent by this session, or it was evicted or deleted). On whatsapp-web.js a message that resolves but cannot be replied to is sent without the quote.",
"content": {
"application/json": {
"schema": {
@@ -5785,7 +5785,7 @@
}
},
"404": {
- "description": "No such message: the id is outside the engine's lookup window (roughly the last hundred messages of the chat, or absent from the Baileys store) or the message was revoked.",
+ "description": "The `quotedMessageId` could not be resolved: the whatsapp-web.js page does not hold it, or the Baileys store does not (it was never received or sent by this session, or it was evicted or deleted). On whatsapp-web.js a message that resolves but cannot be replied to is sent without the quote.",
"content": {
"application/json": {
"schema": {
diff --git a/src/common/openapi/engine-status-responses.ts b/src/common/openapi/engine-status-responses.ts
index 55326cf70..c2ec06eb7 100644
--- a/src/common/openapi/engine-status-responses.ts
+++ b/src/common/openapi/engine-status-responses.ts
@@ -104,6 +104,17 @@ export const MESSAGE_NOT_FOUND_404 =
"No such message: the id is outside the engine's lookup window (roughly the last hundred messages " +
'of the chat, or absent from the Baileys store) or the message was revoked.';
+/**
+ * `MessageNotFoundError` (404) on the send routes that take a `quotedMessageId`. Not the react/delete
+ * wording: whatsapp-web.js looks the quote up by id in the page's message collection and then by
+ * `Msg.getMessagesById`, with no window of recent messages, and does not refuse a quote that resolves
+ * but cannot be replied to.
+ */
+export const QUOTED_MESSAGE_NOT_FOUND_404 =
+ 'The `quotedMessageId` could not be resolved: the whatsapp-web.js page does not hold it, or the ' +
+ 'Baileys store does not (it was never received or sent by this session, or it was evicted or deleted). ' +
+ 'On whatsapp-web.js a message that resolves but cannot be replied to is sent without the quote.';
+
/** `ChannelNotFoundError` (404), on routes addressed by channel id. */
export const CHANNEL_NOT_FOUND_404 =
"No such channel — the id is not among the session's subscribed channels, either because it is " +
diff --git a/src/modules/message/message.controller.ts b/src/modules/message/message.controller.ts
index b14b19a7f..0bb5f36b7 100644
--- a/src/modules/message/message.controller.ts
+++ b/src/modules/message/message.controller.ts
@@ -59,6 +59,7 @@ import {
BULK_MEDIA_TOO_LARGE_413,
MEDIA_URL_PROXY_503,
MESSAGE_NOT_FOUND_404,
+ QUOTED_MESSAGE_NOT_FOUND_404,
RECIPIENT_UNREACHABLE_400,
RECIPIENT_LOOKUP_503,
} from '../../common/openapi/engine-status-responses';
@@ -216,7 +217,7 @@ export class MessageController {
description: 'Session not active or invalid request',
})
@ApiResponse({ status: 409, description: ENGINE_NOT_READY_409 })
- @ApiResponse({ status: 404, description: MESSAGE_NOT_FOUND_404 })
+ @ApiResponse({ status: 404, description: QUOTED_MESSAGE_NOT_FOUND_404 })
@ApiResponse({ status: 501, description: `${CUSTOM_LINK_PREVIEW_501} ${QUOTED_SEND_501}` })
@ApiResponse({ status: 503, description: RECIPIENT_LOOKUP_503 })
async sendText(@Param('sessionId') sessionId: string, @Body() dto: SendTextMessageDto): Promise<MessageResponseDto> {
@@ -267,7 +268,7 @@ export class MessageController {
description: 'Session not active, invalid request, or a url that answers non-2xx, times out or cannot be reached',
})
@ApiResponse({ status: 409, description: ENGINE_NOT_READY_409 })
- @ApiResponse({ status: 404, description: MESSAGE_NOT_FOUND_404 })
+ @ApiResponse({ status: 404, description: QUOTED_MESSAGE_NOT_FOUND_404 })
@ApiResponse({ status: 501, description: `${CHANNEL_MEDIA_501} ${QUOTED_SEND_501}` })
@ApiResponse({ status: 413, description: MEDIA_TOO_LARGE_413 })
@ApiResponse({ status: 503, description: `${MEDIA_URL_PROXY_503} ${RECIPIENT_LOOKUP_503}` })
@@ -295,7 +296,7 @@ export class MessageController {
description: 'Session not active, invalid request, or a url that answers non-2xx, times out or cannot be reached',
})
@ApiResponse({ status: 409, description: ENGINE_NOT_READY_409 })
- @ApiResponse({ status: 404, description: MESSAGE_NOT_FOUND_404 })
+ @ApiResponse({ status: 404, description: QUOTED_MESSAGE_NOT_FOUND_404 })
@ApiResponse({ status: 501, description: `${CHANNEL_MEDIA_501} ${QUOTED_SEND_501}` })
@ApiResponse({ status: 413, description: MEDIA_TOO_LARGE_413 })
@ApiResponse({ status: 503, description: `${MEDIA_URL_PROXY_503} ${RECIPIENT_LOOKUP_503}` })
@@ -323,7 +324,7 @@ export class MessageController {
description: 'Session not active, invalid request, or a url that answers non-2xx, times out or cannot be reached',
})
@ApiResponse({ status: 409, description: ENGINE_NOT_READY_409 })
- @ApiResponse({ status: 404, description: MESSAGE_NOT_FOUND_404 })
+ @ApiResponse({ status: 404, description: QUOTED_MESSAGE_NOT_FOUND_404 })
@ApiResponse({ status: 501, description: `${CHANNEL_MEDIA_501} ${QUOTED_SEND_501}` })
@ApiResponse({ status: 413, description: MEDIA_TOO_LARGE_413 })
@ApiResponse({ status: 503, description: `${MEDIA_URL_PROXY_503} ${RECIPIENT_LOOKUP_503}` })
@@ -351,7 +352,7 @@ export class MessageController {
description: 'Session not active, invalid request, or a url that answers non-2xx, times out or cannot be reached',
})
@ApiResponse({ status: 409, description: ENGINE_NOT_READY_409 })
- @ApiResponse({ status: 404, description: MESSAGE_NOT_FOUND_404 })
+ @ApiResponse({ status: 404, description: QUOTED_MESSAGE_NOT_FOUND_404 })
@ApiResponse({ status: 501, description: `${CHANNEL_MEDIA_501} ${QUOTED_SEND_501}` })
@ApiResponse({ status: 413, description: MEDIA_TOO_LARGE_413 })
@ApiResponse({ status: 503, description: `${MEDIA_URL_PROXY_503} ${RECIPIENT_LOOKUP_503}` })
@@ -377,7 +378,7 @@ export class MessageController {
type: MessageResponseDto,
})
@ApiResponse({ status: 409, description: ENGINE_NOT_READY_409 })
- @ApiResponse({ status: 404, description: MESSAGE_NOT_FOUND_404 })
+ @ApiResponse({ status: 404, description: QUOTED_MESSAGE_NOT_FOUND_404 })
@ApiResponse({ status: 400, description: RECIPIENT_UNREACHABLE_400 })
@ApiResponse({ status: 501, description: wwebjsRefuses501(`a location to ${CHANNEL_OR_BROADCAST}`) })
@ApiResponse({ status: 503, description: RECIPIENT_LOOKUP_503 })
@@ -398,7 +399,7 @@ export class MessageController {
type: MessageResponseDto,
})
@ApiResponse({ status: 409, description: ENGINE_NOT_READY_409 })
- @ApiResponse({ status: 404, description: MESSAGE_NOT_FOUND_404 })
+ @ApiResponse({ status: 404, description: QUOTED_MESSAGE_NOT_FOUND_404 })
@ApiResponse({ status: 400, description: RECIPIENT_UNREACHABLE_400 })
@ApiResponse({ status: 501, description: wwebjsRefuses501(`a contact card to ${CHANNEL_OR_BROADCAST}`) })
@ApiResponse({ status: 503, description: RECIPIENT_LOOKUP_503 })
@@ -419,7 +420,7 @@ export class MessageController {
type: MessageResponseDto,
})
@ApiResponse({ status: 409, description: ENGINE_NOT_READY_409 })
- @ApiResponse({ status: 404, description: MESSAGE_NOT_FOUND_404 })
+ @ApiResponse({ status: 404, description: QUOTED_MESSAGE_NOT_FOUND_404 })
@ApiResponse({ status: 400, description: RECIPIENT_UNREACHABLE_400 })
@ApiResponse({
status: 501,
@@ -447,7 +448,7 @@ export class MessageController {
type: MessageResponseDto,
})
@ApiResponse({ status: 409, description: ENGINE_NOT_READY_409 })
- @ApiResponse({ status: 404, description: MESSAGE_NOT_FOUND_404 })
+ @ApiResponse({ status: 404, description: QUOTED_MESSAGE_NOT_FOUND_404 })
@ApiResponse({ status: 400, description: RECIPIENT_UNREACHABLE_400 })
@ApiResponse({
status: 501,