Skip to content

fix: use maker's language when republishing order on buyer cancel - #821

Merged
grunch merged 1 commit into
lnp2pBot:mainfrom
Matobi98:fix/order-language-on-republish
Jun 8, 2026
Merged

fix: use maker's language when republishing order on buyer cancel#821
grunch merged 1 commit into
lnp2pBot:mainfrom
Matobi98:fix/order-language-on-republish

Conversation

@Matobi98

@Matobi98 Matobi98 commented May 30, 2026

Copy link
Copy Markdown
Contributor

fix: use maker's language when republishing order on buyer cancel

Closes #820

Problem

When a taker with a different language setting cancels an order (causing it to be republished as PENDING), the "Buy SAT" / "Sell SAT" button was rendered in the taker's language instead of the maker's language. This made the
button inconsistent with the rest of the order content, which was already displayed in the maker's language.

Root Cause

In cancelAddInvoice (bot/commands.ts), the republish branch was passing i18nCtx (derived from the calling user, i.e. the taker) to both publishBuyOrderMessage and publishSellOrderMessage. The seller-cancel handler already
handled this correctly by using i18nCtxBuyer / i18nCtxSeller based on order type, but the buyer-cancel side never picked up the same pattern.

Fix

cancelAddInvoice now mirrors the seller-cancel pattern:

  • Buy order (maker = buyer): resolves i18nCtxBuyer from buyerUser and passes it to publishBuyOrderMessage.
  • Sell order (maker = seller): resolves i18nCtxSeller from sellerUser and passes it to publishSellOrderMessage.

This ensures the button text always matches the maker's configured language, regardless of who takes or cancels the order.

Affected file

  • bot/commands.tscancelAddInvoice function, republish branch (~line 372)

Summary by CodeRabbit

  • Bug Fixes
    • Fixed order re-publication messaging to ensure messages are sent to the correct recipient (buyer or seller) with proper language localization when canceling an invoice.

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 30, 2026

Copy link
Copy Markdown
Contributor

Walkthrough

The cancelAddInvoice command now computes and passes buyer/seller-specific i18n contexts when republishing orders. For buy orders, it loads the buyer's context; for sell orders, it loads the seller's context. This fixes incorrect language selection after invoice cancellation.

Changes

Invoice Cancellation i18n Context

Layer / File(s) Summary
i18n context fix in cancelAddInvoice republish
bot/commands.ts
The "re-publish order" branch now computes i18n contexts separately for seller and buyer, setting the appropriate user ID to null and passing the correct target user and context into publishBuyOrderMessage / publishSellOrderMessage.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related issues

Possibly related PRs

  • lnp2pBot/bot#763: Both PRs fix bot/commands.ts cancellation/republish messaging to use separate i18n contexts for buyer vs seller, overlapping on the same i18n-context bug.

Suggested reviewers

  • grunch
  • mostronatorcoder

Poem

A rabbit hops through i18n's maze,
Where buyer and seller in different days,
Now speak in their tongue, no language ablaze,
When orders republish through cancellation's haze! 🐰✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix: use maker's language when republishing order on buyer cancel' directly and clearly summarizes the main change: fixing localization by using the maker's i18n context instead of the taker's when republishing orders.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@ermeme ermeme Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review Summary

Verdict: Approved

I reviewed only the changes in scope for this PR (bot/commands.ts). The fix is narrow, matches the existing seller-cancel pattern, and I did not find blocking issues.

Notes

  • The republish branch now uses the maker's i18n context for both buy and sell orders.
  • This keeps the button text aligned with the order owner's language instead of the canceling user's language.

@Luquitasjeffrey Luquitasjeffrey left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

tACK

@mostronatorcoder mostronatorcoder Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed on current head d3c4fea. The fix is narrow and does what it claims: when cancelAddInvoice republishes the order, it now rebuilds the message with the maker's own i18n context instead of reusing the buyer-side context for both branches. I re-checked the PR comments/reviews and did not find unresolved blocking feedback on the current head.

@grunch
grunch merged commit fefc905 into lnp2pBot:main Jun 8, 2026
5 checks passed
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.

Bug: Buy/Sell SAT button language changes to taker's language after order is republished

3 participants