Track.Artist was a plain string snapshot with no identity, and UserHasTrack doubled as both "in my library" and "I own this", conflating collection membership with administrative ownership. Introduce Artist/TrackArtist to give artist credits their own identity (needed so YouTube tracks with multiple credited artists, and future renames, can be modeled), and Track.OwnerUserId to represent ownership explicitly (local tracks only, enforced by a check constraint). CreateTrack now provisions the uploader's Artist row and links it via TrackArtist; DeleteTrack authorizes against OwnerUserId instead of any UserHasTrack row.
34 lines
935 B
C#
34 lines
935 B
C#
using Musify.Domain.Entities;
|
|
using Musify.Domain.ValueObjects;
|
|
|
|
namespace Musify.Application.Tracks.Responses
|
|
{
|
|
public record TrackApplicationResponse(
|
|
Guid Id,
|
|
string Title,
|
|
string? Artist,
|
|
TrackSource Source,
|
|
string? ExternalId,
|
|
ProcessingStatus AudioStatus,
|
|
int Duration,
|
|
int ListensCount,
|
|
long? OwnerUserId,
|
|
DateTime CreatedAt,
|
|
DateTime UpdatedAt)
|
|
{
|
|
public static TrackApplicationResponse FromEntity(Track track, int listensCount) =>
|
|
new(
|
|
track.Id,
|
|
track.Title,
|
|
track.Artist,
|
|
track.Source,
|
|
track.ExternalId,
|
|
track.AudioTranscodeProcessingStatus,
|
|
track.Duration,
|
|
listensCount,
|
|
track.OwnerUserId,
|
|
track.CreatedAt,
|
|
track.UpdatedAt);
|
|
}
|
|
}
|