Commit a5ed73f
fix(baileys): Improve getMessage pagination to handle message lookup correctly
- Replace arbitrary limit of 100 messages with proper pagination
- Search through messages in batches (100 at a time, up to 10,000 total)
- Order by creation time descending for most recent messages first
- Stop searching once message is found instead of searching all
- Return immediately when matching key.id is found
- Prevents potential loss of messages in busy instances
Resolves Sourcery AI feedback on non-deterministic message lookup.
🤖 Generated with Claude Code
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>1 parent 4c8a13c commit a5ed73f
File tree
1 file changed
+46
-31
lines changed- src/api/integrations/channel/whatsapp
1 file changed
+46
-31
lines changedLines changed: 46 additions & 31 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
522 | 522 | | |
523 | 523 | | |
524 | 524 | | |
525 | | - | |
526 | | - | |
527 | | - | |
528 | | - | |
529 | | - | |
530 | | - | |
531 | | - | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
532 | 540 | | |
533 | | - | |
534 | | - | |
535 | | - | |
536 | | - | |
537 | | - | |
538 | | - | |
539 | | - | |
| 541 | + | |
| 542 | + | |
540 | 543 | | |
541 | | - | |
542 | 544 | | |
543 | | - | |
544 | | - | |
545 | | - | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
546 | 554 | | |
547 | | - | |
548 | | - | |
549 | | - | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
550 | 559 | | |
551 | | - | |
552 | | - | |
553 | | - | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
554 | 563 | | |
555 | | - | |
556 | | - | |
| 564 | + | |
| 565 | + | |
557 | 566 | | |
558 | | - | |
559 | | - | |
560 | | - | |
561 | | - | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
562 | 575 | | |
| 576 | + | |
| 577 | + | |
563 | 578 | | |
564 | 579 | | |
565 | | - | |
| 580 | + | |
566 | 581 | | |
567 | 582 | | |
568 | 583 | | |
| |||
0 commit comments