Skip to content

Implement support for 'too-many-requests' CantDo reason #528

@coderabbitai

Description

@coderabbitai

Summary

The protocol documentation (added in #527) documents too-many-requests as a supported CantDo reason, but the mobile app does not implement it.

Problem

If the Mostro server sends a CantDo message with reason too-many-requests, the following failures occur:

  1. CantDoReason enum (lib/data/models/enums/cant_do_reason.dart) has no tooManyRequests variant.
  2. CantDoReason.fromString() will throw an ArgumentError for the unrecognized value, causing CantDo.fromJson() to fail with a FormatException.
  3. CantDoNotificationMapper._messageMap (lib/shared/widgets/notification_listener_widget.dart) has no entry for 'too_many_requests', so no user-friendly message would be shown even if parsing succeeded.

Expected Fix

  • Add a tooManyRequests variant to the CantDoReason enum in lib/data/models/enums/cant_do_reason.dart.
  • Ensure CantDoReason.fromString() recognizes the "too_many_requests" string.
  • Add a corresponding entry for 'too_many_requests' in CantDoNotificationMapper._messageMap (lib/shared/widgets/notification_listener_widget.dart) with an appropriate user-facing message (e.g., "You have exceeded the allowed request rate. Please try again later.").

References

/cc @Catrya

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions