1.7 KiB
1.7 KiB
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
-
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.
- Apple Music URLs can include
-
Detector does not parse Markdown/HTML links
- Matrix
formatted_bodyor Slack-style<url|text>formats won’t be parsed, only raw URLs. - Consider optional parsing of formatted content if available.
- Matrix
-
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.
- Handler selects
-
API error handling omits response body
ResolvereturnsAPI returned status %dwithout details, making debugging harder.- Consider reading up to N bytes of body on error for logging.
-
Service mapping lacks Qobuz even though enum exists
ServiceQobuzdefined 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).