Skip to content

Conversation

@Matobi98
Copy link

@Matobi98 Matobi98 commented Jan 12, 2026

Summary by CodeRabbit

  • New Features

    • Two-step release workflow: selecting an order now shows a confirmation dialog with order details (ID, counterparty, sats and fiat) and explicit Confirm / Cancel actions to prevent accidental fund releases.
    • Added a cancellation notice when a release is aborted.
  • Localization

    • Expanded translations across locales to support the confirmation flow and new earnings-related UI strings (confirm/cancel labels, cancellation text, earnings/premium/discount, withdraw/invoice messages).

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 12, 2026

Walkthrough

Adds a two-step release confirmation flow: a new exported message builder that shows order details and confirm/cancel buttons, inline callback handlers for show/confirm/cancel release added to the bot start file (duplicated in two locations), and localization strings updated across multiple locale files.

Changes

Cohort / File(s) Summary
Release confirmation core
bot/messages.ts
Import Order, User, Community; add and export showReleaseConfirmationMessage(ctx, orderId) which loads order and participants, composes localized release_confirmation_message, sends inline keyboard with release_confirm_button / release_cancel_button; adjust showConfirmationButtons() to use show_release_confirmation_<orderId> callback when command is release.
Action handlers (start)
bot/start.ts
Add inline action handlers: show_release_confirmation_<id> (delete message, call showReleaseConfirmationMessage), confirm_release_<id> (delete message, call release(ctx, id)), and cancel_release (delete message, reply release_operation_cancelled). Note: similar handler blocks were added in two places (duplicated).
Localization updates
locales/...
locales/{de,en,es,fa,fr,it,ko,pt,ru,uk}.yaml
Update tap_release to indicate a confirmation step; add release_confirmation_message, release_confirm_button, release_cancel_button, release_operation_cancelled; add earnings-related keys earnings, premium, discount, premium_discount, withdraw_earnings, invoice_expired_earnings across locale files.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐇 I nibble the order, tidy and neat,
ID and sats, the details I meet.
"Confirm or cancel?" I twitch my ear,
A button, a hop — the choice is clear.
Thump-thump, release safe, carrot cheer.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change across all modified files: introducing a release confirmation flow with a new showReleaseConfirmationMessage function, updated handlers, and localized confirmation messages.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
bot/start.ts (1)

909-955: Both /release <id> command and /^release_<id>$/ action still bypass confirmation

The new confirmation flow works correctly when using /release without parameters (routes through showConfirmationButtonsshow_release_confirmation_<id>). However, two bypasses remain:

  1. Direct command with ID: A user can type /release <order_id> to execute the release immediately without confirmation (line 323 in start.ts directly calls release()).
  2. Action handler: The /^release_([0-9a-f]{24})$/ handler at line 910 still bypasses confirmation, though currently no UI buttons trigger it.

Fix both by:

  • Route the /release <id> command path to the confirmation screen (when orderId is provided at line 323)
  • Route the /^release_([0-9a-f]{24})$/ action to showReleaseConfirmationMessage instead of directly calling release()

All required i18n keys (release_confirmation_message, release_confirm_button, release_cancel_button, release_operation_cancelled) are present in all locale files.

🤖 Fix all issues with AI agents
In @locales/es.yaml:
- Around line 514-528: Translate the English label "Order ID" into Spanish in
the release_confirmation_message and remove the hardcoded "@" before
${counterparty} to avoid producing a double-@; update the tap_release,
release_confirmation_message, release_confirm_button and related keys so the
copy is fully Spanish (e.g., "ID de orden" or similar) and leave ${counterparty}
un-prefixed so the caller/templating layer can decide whether to include an @.
Ensure the change is applied to the release_confirmation_message string only and
keep placeholders (${orderId}, ${counterparty}, ${amount}, ${fiatAmount},
${fiatCode}) intact.

In @locales/fa.yaml:
- Around line 513-527: Update the wording to convey "about to release" rather
than an action already in progress by changing the tap_release and the opening
line of release_confirmation_message: replace the current tap_release value with
a Persian phrase like "برای آزادسازی وجه، سفارش را انتخاب کنید؛ قبل از ادامه
تأییدی مشاهده خواهید کرد." and change the first sentence of
release_confirmation_message from "شما در حال آزاد کردن سفارش زیر هستید:" to
"شما در آستانه آزاد کردن سفارش زیر هستید:" (leave the rest of
release_confirmation_message, release_confirm_button, release_cancel_button, and
release_operation_cancelled intact).
🧹 Nitpick comments (2)
bot/start.ts (1)

50-64: Avoid redundant imports from the same module
You import both showReleaseConfirmationMessage and * as messages from ./messages. Prefer one style for consistency (e.g., messages.showReleaseConfirmationMessage).

bot/messages.ts (1)

2031-2033: Consider adding parse_mode for message formatting.

Other similar functions in this file use parse_mode: 'Markdown' or parse_mode: 'MarkdownV2' when sending messages. If the release_confirmation_message locale string contains Markdown formatting (which it does in several locales), the message may not render correctly without specifying the parse mode.

Suggested fix
     await ctx.reply(message, {
       reply_markup: { inline_keyboard: inlineKeyboard },
+      parse_mode: 'Markdown',
     });
📜 Review details

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b8c9043 and 617ecf0.

📒 Files selected for processing (12)
  • bot/messages.ts
  • bot/start.ts
  • locales/de.yaml
  • locales/en.yaml
  • locales/es.yaml
  • locales/fa.yaml
  • locales/fr.yaml
  • locales/it.yaml
  • locales/ko.yaml
  • locales/pt.yaml
  • locales/ru.yaml
  • locales/uk.yaml
🧰 Additional context used
📓 Path-based instructions (3)
{bot/**,locales/**}

📄 CodeRabbit inference engine (AGENTS.md)

House commands, scenes, and middleware modules in bot/ directory and pair new flows with text updates under locales/

Files:

  • locales/ru.yaml
  • locales/fa.yaml
  • locales/uk.yaml
  • locales/pt.yaml
  • locales/fr.yaml
  • locales/ko.yaml
  • locales/it.yaml
  • locales/es.yaml
  • locales/de.yaml
  • locales/en.yaml
  • bot/start.ts
  • bot/messages.ts
**/*.{ts,tsx,js,jsx,json}

📄 CodeRabbit inference engine (AGENTS.md)

Enforce Prettier formatting with 2-space indentation, semicolons, and single quotes; run before committing

Files:

  • bot/start.ts
  • bot/messages.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx,js,jsx}: Use ESLint Standard plus TypeScript rules to guard the codebase; address warnings instead of disabling them
Use camelCase for functions and variables
Use PascalCase for class names

Files:

  • bot/start.ts
  • bot/messages.ts
🧠 Learnings (8)
📚 Learning: 2026-01-02T12:48:28.393Z
Learnt from: CR
Repo: lnp2pBot/bot PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-02T12:48:28.393Z
Learning: Applies to src/bot/**/*.{ts,tsx} : Use custom context types extending Telegraf's base context (MainContext and CommunityContext) for bot command handlers and message processing

Applied to files:

  • bot/start.ts
  • bot/messages.ts
📚 Learning: 2026-01-02T12:48:44.329Z
Learnt from: CR
Repo: lnp2pBot/bot PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-02T12:48:44.329Z
Learning: Applies to {bot/**,locales/**} : House commands, scenes, and middleware modules in `bot/` directory and pair new flows with text updates under `locales/`

Applied to files:

  • bot/start.ts
📚 Learning: 2026-01-02T12:48:28.393Z
Learnt from: CR
Repo: lnp2pBot/bot PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-02T12:48:28.393Z
Learning: Applies to src/ln/**/*.ts : Implement Lightning Network hold invoice pattern: Seller creates order → Buyer takes order → Seller pays hold invoice → Funds held until parties confirm fiat exchange → Hold invoice settled or canceled

Applied to files:

  • bot/start.ts
📚 Learning: 2026-01-02T12:48:28.393Z
Learnt from: CR
Repo: lnp2pBot/bot PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-02T12:48:28.393Z
Learning: Applies to src/bot/middleware/**/*.ts : Apply middleware chain in this order: User validation → Admin checking → Context enhancement → Command routing

Applied to files:

  • bot/start.ts
📚 Learning: 2026-01-02T12:48:28.393Z
Learnt from: CR
Repo: lnp2pBot/bot PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-02T12:48:28.393Z
Learning: Applies to src/bot/**/messages.ts : Use i18n for message templates with YAML localization files for 10 supported languages and store user-specific language preferences in database

Applied to files:

  • bot/messages.ts
📚 Learning: 2026-01-02T12:48:44.329Z
Learnt from: CR
Repo: lnp2pBot/bot PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-02T12:48:44.329Z
Learning: Applies to app.ts : Keep Telegram bot bootstrap and Mongo connection logic centralized in `app.ts`

Applied to files:

  • bot/messages.ts
📚 Learning: 2026-01-02T12:48:28.394Z
Learnt from: CR
Repo: lnp2pBot/bot PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-02T12:48:28.394Z
Learning: Applies to src/models/User.ts : Store user-specific language preferences in the database and enable dynamic language switching with grammyjs/i18n

Applied to files:

  • bot/messages.ts
📚 Learning: 2026-01-02T12:48:28.393Z
Learnt from: CR
Repo: lnp2pBot/bot PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-02T12:48:28.393Z
Learning: Applies to src/models/Order.ts : Implement order status lifecycle transitions: PENDING → ACTIVE → FIAT_SENT → COMPLETED, with dispute states (DISPUTE, CANCELED_BY_ADMIN) and failed states (EXPIRED, CANCELED)

Applied to files:

  • bot/messages.ts
🧬 Code graph analysis (5)
locales/ru.yaml (3)
bot/modules/orders/messages.ts (1)
  • i18n (57-85)
bot/ordersActions.ts (1)
  • i18n (190-269)
bot/commands.ts (1)
  • ctx (806-839)
locales/uk.yaml (2)
bot/modules/orders/scenes.ts (3)
  • fiatAmount (136-146)
  • currency (110-135)
  • fiatAmount (247-250)
bot/scenes.ts (1)
  • ctx (204-236)
locales/fr.yaml (1)
bot/modules/orders/messages.ts (1)
  • i18n (57-85)
bot/start.ts (4)
bot/middleware/user.ts (1)
  • userMiddleware (9-19)
bot/modules/community/communityContext.ts (1)
  • CommunityContext (18-22)
bot/messages.ts (1)
  • showReleaseConfirmationMessage (2153-2153)
bot/commands.ts (1)
  • release (885-885)
bot/messages.ts (2)
bot/start.ts (1)
  • MainContext (79-84)
models/index.ts (2)
  • Order (9-9)
  • User (9-9)
🔇 Additional comments (10)
locales/uk.yaml (1)

510-524: Release confirmation strings look consistent and well-structured
Placeholders and the warning/CTA read correctly for the new flow.

locales/en.yaml (1)

519-533: English confirmation flow strings look correct and consistent
Keys and placeholders match the intended confirm/cancel UX.

locales/ru.yaml (1)

513-527: RU confirmation strings are consistent with the new flow
No issues in the added confirmation block/keys.

locales/fr.yaml (1)

512-526: FR confirmation strings look good
Clear warning + confirm/cancel labels; placeholders align with expected variables.

bot/messages.ts (2)

1975-1978: LGTM!

The conditional routing for release commands to the confirmation flow is cleanly implemented and follows the existing pattern.


21-21: LGTM!

The import of Order and User models is appropriate for the new database lookups in showReleaseConfirmationMessage.

locales/it.yaml (1)

510-524: LGTM!

The Italian translations for the release confirmation flow are complete and use the correct placeholders (${orderId}, ${counterparty}, ${amount}, ${fiatAmount}, ${fiatCode}) that match the parameters passed in showReleaseConfirmationMessage.

locales/pt.yaml (1)

512-526: LGTM!

The Portuguese translations for the release confirmation flow are complete and consistent with the other locale files.

locales/ko.yaml (1)

510-524: LGTM!

The Korean translations for the release confirmation flow are complete and properly localized.

locales/de.yaml (1)

513-527: LGTM!

The German translations for the release confirmation flow are complete and maintain consistent formal language ("Sie") used throughout the file.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
locales/ru.yaml (1)

528-533: Untranslated strings in Russian locale.

The earnings-related keys (earnings, withdraw_earnings, invoice_expired_earnings) remain in English while the release confirmation flow has been properly translated to Russian. For consistency, these should be translated.

Suggested Russian translations
-earnings: Earnings
-premium: Premium
-discount: Discount
-premium_discount: premium/discount
-withdraw_earnings: Withdraw earnings
-invoice_expired_earnings: The invoice has expired, resubmit a withdrawal request with a new invoice.
+earnings: Доход
+premium: Премия
+discount: Скидка
+premium_discount: премия/скидка
+withdraw_earnings: Вывести доход
+invoice_expired_earnings: Срок действия счета истек, повторите запрос на вывод с новым счетом.

@Matobi98
Copy link
Author

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)

locales/ru.yaml (1)> 528-533: Untranslated strings in Russian locale.

The earnings-related keys (earnings, withdraw_earnings, invoice_expired_earnings) remain in English while the release confirmation flow has been properly translated to Russian. For consistency, these should be translated.

Suggested Russian translations

-earnings: Earnings
-premium: Premium
-discount: Discount
-premium_discount: premium/discount
-withdraw_earnings: Withdraw earnings
-invoice_expired_earnings: The invoice has expired, resubmit a withdrawal request with a new invoice.
+earnings: Доход
+premium: Премия
+discount: Скидка
+premium_discount: премия/скидка
+withdraw_earnings: Вывести доход
+invoice_expired_earnings: Срок действия счета истек, повторите запрос на вывод с новым счетом.

This is ouside of the scope of this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants