feat: Stream Now instant-play of a random track from the nav button
This commit is contained in:
@@ -72,6 +72,30 @@ public class TrackController : ControllerBase
|
||||
return Ok(result.Value);
|
||||
}
|
||||
|
||||
// GET api/track/random (unauthenticated)
|
||||
// Picks one track at random from the full library and returns its metadata. Public, same auth
|
||||
// posture as GET api/track/page. Selection math lives in the SQL service/repository, not here.
|
||||
// 404 when the library is empty (a valid state the client renders as "no tracks yet"), 200 +
|
||||
// TrackDto otherwise. Literal segment, declared before "{trackId}" so it never routes there.
|
||||
[HttpGet("random")]
|
||||
public async Task<ActionResult> GetRandom(CancellationToken cancellationToken = default)
|
||||
{
|
||||
var result = await _sqlTrackService.GetRandom(cancellationToken);
|
||||
if (!result.Success)
|
||||
{
|
||||
var error = result.Messages.FirstOrDefault()?.Message ?? "Unknown error";
|
||||
_logger.LogError("GetRandom failed: {Error}", error);
|
||||
return StatusCode(500, "Failed to load track");
|
||||
}
|
||||
|
||||
if (result.Value is null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return Ok(result.Value);
|
||||
}
|
||||
|
||||
// GET api/track/waveform-status ([ApiKeyAuthorize])
|
||||
// Admin backfill view: returns every track with a flag for whether a waveform profile is
|
||||
// stored in the WaveformProfiles vault. The catalogue is small enough that the CMS panel reads
|
||||
|
||||
Reference in New Issue
Block a user