[NOWEB] - Validate JID before sending /api/sendText (and other) to it - extact logic from webjs client
Engine: NOWEB
Describe the bug:
When making a request to /api/sendText with a phone number in an incorrect format (such as local format without international prefix), the request hangs indefinitely. This is likely due to the WA server never sending an acknowledgment (ACK) because the phone number format is invalid.
This creates instability and confusion in the system because requests remain pending indefinitely instead of failing immediately.
Expected Behavior:
The request should immediately fail with a clear error message, like "Invalid phone number format," instead of waiting indefinitely for an ACK from WhatsApp.
Steps to Reproduce:
Make an API request to /api/sendText with an invalid phone number format:
{ "chatId": "0532030482", "text": "Test Message", "session": "etx" }
Notice that the request never completes and no error is returned.
Suggested Fix (optional):
Add immediate phone-number format validation at the API level to return clear errors quickly, instead of relying solely on WA ACK response.
before sending message to unknown number you can use https://waha.devlike.pro/docs/how-to/contacts/#check-phone-number-exists to validate that the number exists and get the actually jid for that number (shit happenes with old brazilian phone numbers)
I've checked and it looks that WA server just didn't return any response and drop the message completely. We'll try to extract the validation logic from the current official app, but it'll take time and not the priority right now, because there's a well-tested method to validate the number
Use Check Phone Number Exists whenever you send a message from user-defined input.
Usually no needs to check it if you get a message via webhooks, it has the right chatId already