UX: keep withdrawal session active after failed community earnings payment - #784
Conversation
WalkthroughThe changes add a filter condition to detect expired invoices in the earnings wizard, incorporate "withdraw earnings" buttons into payment failure notifications, introduce a new localization key for earnings-specific payment failures across ten languages, and update a development dependency version. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
jobs/pending_payments.ts (1)
198-216:⚠️ Potential issue | 🟡 MinorStop flow after marking an earnings invoice as expired.
After sending
invoice_expired_earnings, execution continues into the generic failure path. On a max-attempt run, users can receive both “expired invoice” and terminal “failed” messages in the same cycle. Short-circuit this branch.Suggested fix
if (!!payment && payment.is_expired) { pending.is_invoice_expired = true; await bot.telegram.sendMessage( user.tg_id, i18nCtx.t('invoice_expired_earnings'), { reply_markup: { inline_keyboard: [ [ { text: i18nCtx.t('withdraw_earnings'), callback_data: `withdrawEarnings_${pending.community_id}`, }, ], ], }, }, ); + continue; }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@jobs/pending_payments.ts` around lines 198 - 216, This branch marks an invoice expired and sends invoice_expired_earnings via bot.telegram.sendMessage but then falls through into the generic failure handling; after setting pending.is_invoice_expired = true and sending the message, short-circuit further processing for that pending (e.g., add a continue to the enclosing loop or return from the per-pending handler) so it does not also trigger the terminal "failed" path; locate the code around payment, pending, bot.telegram.sendMessage and the invoice_expired_earnings/i18nCtx usage and stop the flow immediately after the sendMessage call.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@jobs/pending_payments.ts`:
- Around line 198-216: This branch marks an invoice expired and sends
invoice_expired_earnings via bot.telegram.sendMessage but then falls through
into the generic failure handling; after setting pending.is_invoice_expired =
true and sending the message, short-circuit further processing for that pending
(e.g., add a continue to the enclosing loop or return from the per-pending
handler) so it does not also trigger the terminal "failed" path; locate the code
around payment, pending, bot.telegram.sendMessage and the
invoice_expired_earnings/i18nCtx usage and stop the flow immediately after the
sendMessage call.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 08d21974-d62b-4c0c-8bab-794a4db41827
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (13)
bot/modules/community/scenes.tsjobs/pending_payments.tslocales/de.yamllocales/en.yamllocales/es.yamllocales/fa.yamllocales/fr.yamllocales/it.yamllocales/ko.yamllocales/pt.yamllocales/ru.yamllocales/uk.yamlpackage.json
Related issue
Closes #768
Problem
When a community admin's earnings withdrawal fails (payment exhausts all attempts or invoice expires), the bot sends an error message but leaves the admin with no way to retry without navigating back to the menu. If the admin tries to
send a new invoice directly, the bot responds with "I don't understand what you're saying."
Solution
Instead of leaving the admin stranded after a failure, the bot now sends an inline button alongside the error message that re-enters the withdrawal wizard directly. The admin can retry with a new invoice in one click, without going
back to the community menu.
Additionally, a related bug was fixed: if a withdrawal failed due to an expired invoice, the wizard would incorrectly block a new submission with "I'm already trying to pay this" because the expired record was still being matched by
the pending payment query.
Changes
jobs/pending_payments.ts: both terminal failure cases (expired invoice and max attempts reached) now include an inline "Withdraw Earnings" button alongside the error message, and use a new dedicated message key instead of thegeneric order payment failure message
bot/modules/community/scenes.ts: the pending payment check now excludes expired invoice records so they don't block retrieslocales/*.yaml(10 files): newpending_payment_failed_earningskey with messaging specific to community earnings withdrawalsSummary by CodeRabbit
Bug Fixes
New Features
Documentation