Track get-or-create for YouTube videos was duplicated between the old GetYouTubeTrackStream query handler (which also wrote to the database) and AddYouTubeTrackToPlayList, with frontend-supplied metadata (title/artist/duration/thumbnail) trusted at add-to-playlist time instead of resolving it server-side. Extract YouTubeTrackProvisioner as the single get-or-create path, resolving structured artist refs (id + name) from YouTube Music so multi-artist songs map to distinct Artist rows. Rename GetYouTubeTrackStream to ResolveYouTubeTrackStream (it writes, so it is a command, not a query) and delegate to the provisioner. AddYouTubeTrackToPlayList slims down to (UserId, PlayListId, VideoId) since all metadata now comes from the provisioner/YouTube API.
15 lines
375 B
C#
15 lines
375 B
C#
using FluentValidation;
|
|
using Musify.Api.DataTransferObjects.PlayLists;
|
|
|
|
namespace Musify.Api.Validators.PlayLists;
|
|
|
|
public sealed class AddYouTubeTrackRequestValidator : AbstractValidator<AddYouTubeTrackRequest>
|
|
{
|
|
public AddYouTubeTrackRequestValidator()
|
|
{
|
|
RuleFor(x => x.VideoId)
|
|
.NotEmpty()
|
|
.Matches("^[A-Za-z0-9_-]{11}$");
|
|
}
|
|
}
|