Bugfix: Distinguish i18n contexts for buyer and seller in cancelShowH…#763
Bugfix: Distinguish i18n contexts for buyer and seller in cancelShowH…#763Matobi98 wants to merge 1 commit intolnp2pBot:mainfrom
Conversation
WalkthroughThis pull request refactors cancellation logic in bot/commands.ts to implement per-user i18n contexts. The cancelAddInvoice and cancelShowHoldInvoice functions now distinguish between seller and buyer contexts when sending messages, replacing a single unified context with role-specific ones. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 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.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@bot/commands.ts`:
- Around line 499-504: The guard that checks order.status !== 'WAITING_PAYMENT'
currently always sends messages.genericErrorMessage(ctx, sellerUser,
i18nCtxSeller) which can DM the wrong person; change it to send the error to the
acting user instead: determine the acting user (the request initiator used
earlier in cancelOrder — e.g., the variable representing the caller) and its
i18n context (from getUserI18nContext), then call
messages.genericErrorMessage(ctx, actingUser, actingI18nCtx) when the status is
invalid, leaving sellerUser/buyerUser untouched for other flows.
There was a problem hiding this comment.
Code Review ✅
Clean fix for the i18n context bug. Each party now receives messages in their own language.
Changes verified
| Message | Recipient | Context Used |
|---|---|---|
toSellerDidntPayInvoiceMessage |
Seller | i18nCtxSeller ✅ |
toBuyerSellerDidntPayInvoiceMessage |
Buyer | i18nCtxBuyer ✅ |
successCancelOrderMessage (buyer) |
Buyer | i18nCtxBuyer ✅ |
counterPartyCancelOrderMessage |
Seller | i18nCtxSeller ✅ |
publishBuyOrderMessage |
Buyer | i18nCtxBuyer ✅ |
publishSellOrderMessage |
Seller | i18nCtxSeller ✅ |
toAdminChannelSellerDidntPayInvoiceMessage |
Admin (about seller) | i18nCtxSeller ✅ |
Error handling improvement ✅
Explicit throw new Error when buyer/seller not found — better than silent return.
Code structure ✅
- Both users fetched early, before any logic
- i18n contexts created once, reused throughout
- Variable renamed from
usertosellerUserfor clarity
CI ✅
All checks passing.
Summary
LGTM. Simple and correct fix.
PR: Fix Timeout/Expiry Notifications Language Localization
Overview
This PR fixes a bug where timeout/expiry notifications for sell orders were being sent to both the buyer and the seller in the buyer's configured language. The system now correctly identifies each user's language preference and sends personalized notifications.
Key Changes
Language Localization
Updated
cancelShowHoldInvoiceinbot/commands.tsto fetch bothbuyerUserandsellerUserdata.Individual i18n Contexts
Every party now has their own i18n context retrieved via
getUserI18nContext().Targeted Messaging
Outgoing message functions:
toSellerDidntPayInvoiceMessagetoBuyerSellerDidntPayInvoiceMessagepublishBuyOrderMessageNow receive the specific language context for the recipient.
Error Handling
Added an explicit exception if the seller user is not found during the cancellation process to improve reliability.
Summary by CodeRabbit