musiclink/docs/reviews/message-handling.md

1.7 KiB
Raw Blame History

Code Review: Message Handling & Link Detection

Scope

  • internal/detector/
  • internal/resolver/
  • internal/services/

Findings

Strengths

  • Regex detection is consolidated in one place; uses a single pattern for all supported services.
  • Resolver encapsulates the idonthavespotify API and wraps errors with context.
  • Output formatting is consistent and service ordering is explicit.

⚠️ Issues / Opportunities

  1. Detector misses some common URL variants

    • Apple Music URLs can include music.apple.com/{country}/album/... but also have track URLs and other forms not matched.
    • Spotify short links (https://spoti.fi/...) are not detected.
    • Consider adding more variants or making the detector extensible with service-specific regexes.
  2. Detector does not parse Markdown/HTML links

    • Matrix formatted_body or Slack-style <url|text> formats wont be parsed, only raw URLs.
    • Consider optional parsing of formatted content if available.
  3. Resolver only processes the first link

    • Handler selects links[0], ignoring additional links in the message.
    • Consider responding to multiple links or clarifying this behavior in docs.
  4. API error handling omits response body

    • Resolve returns API returned status %d without details, making debugging harder.
    • Consider reading up to N bytes of body on error for logging.
  5. Service mapping lacks Qobuz even though enum exists

    • ServiceQobuz defined but never populated; detector/formatting do not include it.
    • Consider either supporting or removing it to avoid dead config.

Notes

  • Formatting uses title for track only; artist metadata is not used even if present (currently not parsed from API response).