Skip to content

fix: implement support for 'too-many-requests' CantDo reason#530

Open
Deepak8858 wants to merge 2 commits intoMostroP2P:mainfrom
Deepak8858:fix/issue-528-too-many-requests
Open

fix: implement support for 'too-many-requests' CantDo reason#530
Deepak8858 wants to merge 2 commits intoMostroP2P:mainfrom
Deepak8858:fix/issue-528-too-many-requests

Conversation

@Deepak8858
Copy link

@Deepak8858 Deepak8858 commented Mar 13, 2026

This PR implements support for the too-many-requests CantDo reason as documented in the protocol.\n\nChanges:\n- Added tooManyRequests variant to CantDoReason enum in lib/data/models/enums/cant_do_reason.dart\n- Added localized messages for tooManyRequests in intl_en.arb and intl_es.arb\n- Added mapping for too_many_requests in CantDoNotificationMapper in lib/shared/widgets/notification_listener_widget.dart\n\nFixes #528

Summary by CodeRabbit

  • New Features
    • Added a user-facing rate-limit message that informs users they have exceeded allowed requests and to try again later.
    • Localized the new message in English, Spanish, and Italian so notifications appear in the user’s language.
    • Integrated the message into existing notification and message-detail views so it is shown where relevant.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 13, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 4a2c6a00-92df-4bbe-b6f2-a412471b7f04

📥 Commits

Reviewing files that changed from the base of the PR and between 2c050c0 and 89ccfd3.

📒 Files selected for processing (2)
  • lib/features/trades/widgets/mostro_message_detail_widget.dart
  • lib/l10n/intl_it.arb

Walkthrough

Adds support for the too-many-requests CantDo reason: new enum member, localized strings (EN/ES/IT), and mappings so the reason is parsed and shown to users in notifications and message detail views.

Changes

Cohort / File(s) Summary
CantDoReason enum
lib/data/models/enums/cant_do_reason.dart
Appended new enum member tooManyRequests('too_many_requests') (adjusted trailing punctuation to continue the list).
Localization files
lib/l10n/intl_en.arb, lib/l10n/intl_es.arb, lib/l10n/intl_it.arb
Added tooManyRequests localization key with English, Spanish, and Italian messages.
Notification mapping
lib/shared/widgets/notification_listener_widget.dart
Added 'too_many_requests' entry to CantDoNotificationMapper._messageMap mapping to S.of(context)!.tooManyRequests.
Message detail UI
lib/features/trades/widgets/mostro_message_detail_widget.dart
Handled CantDoReason.tooManyRequests in cant-do message generation, using localized tooManyRequests string.

Sequence Diagram(s)

sequenceDiagram
  participant Server
  participant Parser as CantDo.fromJson
  participant Enum as CantDoReason
  participant UI as NotificationMapper / MessageDetail
  Server->>Parser: Send CantDo(reason: "too_many_requests")
  Parser->>Enum: CantDoReason.fromString("too_many_requests")
  Enum-->>Parser: tooManyRequests
  Parser->>UI: Provide CantDo(reason: tooManyRequests)
  UI->>UI: Map to S.of(context)!.tooManyRequests
  UI-->>User: Show localized "too many requests" message
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • grunch

Poem

🐰 I saw the server tire and rest,

Too many hops, it needs a jest.
I nibble keys and stitch a phrase —
"Please wait a moment" in three ways.
🥕✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding support for the 'too-many-requests' CantDo reason throughout the codebase.
Linked Issues check ✅ Passed The PR implements all three requirements from issue #528: adds tooManyRequests enum variant, implements string parsing via enum conversion, and adds notification mappings with localized messages.
Out of Scope Changes check ✅ Passed All changes are directly scoped to issue #528 requirements: enum variant, localization keys, and notification mapper entries. Italian localization addition aligns with completeness of supporting all app languages.
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 unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
📝 Coding Plan
  • Generate coding plan for human review comments

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: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@lib/data/models/enums/cant_do_reason.dart`:
- Around line 26-27: The CantDo enum now includes tooManyRequests but the switch
in the trade-detail display (in
lib/features/trades/widgets/mostro_message_detail_widget.dart) still falls
through to a generic message; update the switch that inspects the CantDo reason
(look for the switch or map handling code around the CantDo case in the widget
rendering function) to add an explicit case for CantDoReason.tooManyRequests and
return the appropriate user-facing message/Widget (e.g., explain rate limiting /
retry interval) instead of the generic fallback, preserving the existing pattern
used by other cases like pendingOrderExists.

In `@lib/l10n/intl_en.arb`:
- Line 4: Add the missing "tooManyRequests" localization key to
lib/l10n/intl_it.arb with the Italian translation for "You have exceeded the
allowed request rate. Please try again later." (use the same key
"tooManyRequests"), then run the Flutter localization build command `dart run
build_runner build -d` to regenerate the localization outputs so the new string
is included in the generated classes.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d15971a0-076f-4232-afb5-25c6a84e0ce7

📥 Commits

Reviewing files that changed from the base of the PR and between 902a650 and 2c050c0.

📒 Files selected for processing (4)
  • lib/data/models/enums/cant_do_reason.dart
  • lib/l10n/intl_en.arb
  • lib/l10n/intl_es.arb
  • lib/shared/widgets/notification_listener_widget.dart

Copy link
Member

@Catrya Catrya left a comment

Choose a reason for hiding this comment

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

Hi @Deepak8858 wellcome! Please follow the suggestions provided by CodeRabbit. If you have any questions, please ask us.

@Deepak8858
Copy link
Author

I have addressed the feedback from CodeRabbit:

  1. Added case to .
  2. Added localization to .

Note: I could not run locally, so I am relying on CI to regenerate the localization classes.

@Deepak8858
Copy link
Author

I have verified the code against the suggestions. The explicit case for CantDoReason.tooManyRequests is already present in mostro_message_detail_widget.dart, and the localization key is already included in intl_it.arb.

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