Commit d1ff63e
fix(instance): resolve empty pairing code on POST /instance/pair
The Pair function was calling PairPhone directly without checking if
the client was initialized, and was silently swallowing errors from
PairPhone. This caused two problems:
1. If the client was nil or disconnected, PairPhone returned an error
but the function ignored it and returned HTTP 200 with an empty
PairingCode field, misleading the caller into thinking it succeeded.
2. The client was never started before PairPhone was called. WhatsApp
requires the client to be connected to the WA websocket (waiting
for auth) before a pairing code can be generated.
Fix:
- Start the instance automatically if no active connection exists,
mirroring the QR code flow
- Wait 3 seconds for the WA websocket connection to establish and
the initial QR generation to begin (required by whatsmeow before
PairPhone can be called)
- Reject early if the instance is already authenticated
- Return PairPhone errors to the caller instead of swallowing them,
so the handler correctly responds with HTTP 500 and an actionable
error message
Fixes #211 parent afbdef4 commit d1ff63e
1 file changed
Lines changed: 28 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
471 | 471 | | |
472 | 472 | | |
473 | 473 | | |
474 | | - | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
475 | 500 | | |
476 | | - | |
| 501 | + | |
| 502 | + | |
477 | 503 | | |
478 | 504 | | |
479 | 505 | | |
| |||
0 commit comments