mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 16:11:10 +00:00
Removes track path editing from the music track update flow
Stops Track.UpdateDetails and Artist.UpdateTrackInAlbum from assigning a path, so a track path can be set only when the track is created. Removes Path from UpdateTrackRequest, UpdateTrackCommand, UpdateTrackCommandValidator and UpdateMusicTrackRequest, and removes the path containment check and IPathService dependency from UpdateTrackCommandHandler. The path stays visible in TrackResponse, MusicTrackDto and the read-only field of the track page. Updates the endpoint summary, request and API docs, and the affected tests.
This commit is contained in:
1 parent
728a879bb8
commit
1aa427b1e2
29 files changed
+47
-243
No files matched your search
-1
@@ -158,7 +158,6 @@ public static class UpdateArtistCommandMapping
|
||||
Result<Updated> updateTrackResult = artist.UpdateTrackInAlbum(
|
||||
existingAlbum,
|
||||
existingTrack,
|
||||
domainTrack.Path,
|
||||
domainTrack.Metadata,
|
||||
domainTrack.Disambiguation,
|
||||
domainTrack.TrackNumber,
|
||||
|
||||
-1
@@ -111,7 +111,6 @@ public static class AudioMetadataDtoMapping
|
||||
return artist.UpdateTrackInAlbum(
|
||||
album,
|
||||
track,
|
||||
track.Path,
|
||||
metadataResult.Value,
|
||||
disambiguation,
|
||||
track.TrackNumber,
|
||||
|
||||
-1
@@ -85,7 +85,6 @@ public static class UpdateTrackCommandMapping
|
||||
Result<Updated> updateResult = artist.UpdateTrackInAlbum(
|
||||
album,
|
||||
track,
|
||||
command.Path!,
|
||||
metadataResult.Value,
|
||||
Optional<string>.FromNullable(metadata.Disambiguation),
|
||||
command.TrackNumber!.Value,
|
||||
|
||||
-1
@@ -26,7 +26,6 @@ public static class UpdateTrackRequestMapping
|
||||
artistId,
|
||||
albumId,
|
||||
trackId,
|
||||
request.Path,
|
||||
request.Metadata,
|
||||
request.TrackNumber,
|
||||
request.DiscNumber,
|
||||
|
||||
-2
@@ -19,7 +19,6 @@ namespace Lumina.Application.Core.MediaLibrary.AudioLibrary.MusicLibrary.Tracks.
|
||||
/// <param name="ArtistId">The unique identifier of the artist this track belongs to, taken from the route.</param>
|
||||
/// <param name="AlbumId">The unique identifier of the album this track belongs to, taken from the route.</param>
|
||||
/// <param name="TrackId">The unique identifier of the track, taken from the route.</param>
|
||||
/// <param name="Path">The file system path of the track.</param>
|
||||
/// <param name="Metadata">The audio metadata of the track.</param>
|
||||
/// <param name="TrackNumber">The number of the track on its disc.</param>
|
||||
/// <param name="DiscNumber">The number of the disc the track belongs to, if applicable.</param>
|
||||
@@ -39,7 +38,6 @@ public record UpdateTrackCommand(
|
||||
string? ArtistId,
|
||||
string? AlbumId,
|
||||
string? TrackId,
|
||||
string? Path,
|
||||
MusicTrackMetadataDto? Metadata,
|
||||
int? TrackNumber,
|
||||
int? DiscNumber,
|
||||
|
||||
+1
-21
@@ -26,7 +26,6 @@ using Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.ExternalIden
|
||||
using Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.MusicLibraryAggregate;
|
||||
using Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.MusicLibraryAggregate.Entities;
|
||||
using Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.MusicLibraryAggregate.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Services;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.AudioLibrary;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Common;
|
||||
using System;
|
||||
@@ -48,7 +47,6 @@ public class UpdateTrackCommandHandler : ICommandHandler<UpdateTrackCommand, Res
|
||||
private readonly IAuthorizationService _authorizationService;
|
||||
private readonly ICurrentUserService _currentUserService;
|
||||
private readonly IValidator<UpdateTrackCommand> _validator;
|
||||
private readonly IPathService _pathService;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UpdateTrackCommandHandler"/> class.
|
||||
@@ -57,14 +55,12 @@ public class UpdateTrackCommandHandler : ICommandHandler<UpdateTrackCommand, Res
|
||||
/// <param name="authorizationService">Injected service for authorization related functionality.</param>
|
||||
/// <param name="currentUserService">Injected service to retrieve the current user information.</param>
|
||||
/// <param name="validator">Injected validator for application validation rules.</param>
|
||||
/// <param name="pathService">Injected service for file system path related functionality.</param>
|
||||
public UpdateTrackCommandHandler(IUnitOfWork unitOfWork, IAuthorizationService authorizationService, ICurrentUserService currentUserService, IValidator<UpdateTrackCommand> validator, IPathService pathService)
|
||||
public UpdateTrackCommandHandler(IUnitOfWork unitOfWork, IAuthorizationService authorizationService, ICurrentUserService currentUserService, IValidator<UpdateTrackCommand> validator)
|
||||
{
|
||||
_unitOfWork = unitOfWork;
|
||||
_authorizationService = authorizationService;
|
||||
_currentUserService = currentUserService;
|
||||
_validator = validator;
|
||||
_pathService = pathService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -127,11 +123,6 @@ public class UpdateTrackCommandHandler : ICommandHandler<UpdateTrackCommand, Res
|
||||
if (getLibraryResult.Value is null)
|
||||
return Errors.Library.LibraryNotFound;
|
||||
|
||||
// A track is only readable if it is stored inside one of the content locations of its library, so a client can never edit an entry
|
||||
// that points the reading pipeline at an arbitrary file of the host.
|
||||
if (!AreTrackPathsWithinLibraryContentLocations(getLibraryResult.Value, command))
|
||||
return Errors.Music.TrackPathMustBeWithinLibraryContentLocations;
|
||||
|
||||
// Media contributors are referenced by Id and are never created implicitly by editing a track, so each one must already exist.
|
||||
Result<IReadOnlyList<MediaContributorEntity>> getContributorsResult = await GetExistingContributorsAsync(command, cancellationToken).ConfigureAwait(false);
|
||||
if (getContributorsResult.IsFailure)
|
||||
@@ -164,17 +155,6 @@ public class UpdateTrackCommandHandler : ICommandHandler<UpdateTrackCommand, Res
|
||||
return getPersistedTrackResult.Value.ToResponse();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the track path referenced by <paramref name="command"/> is stored inside one of the content locations of <paramref name="library"/>.
|
||||
/// </summary>
|
||||
/// <param name="library">The media library that owns the track.</param>
|
||||
/// <param name="command">The command carrying the referenced track.</param>
|
||||
/// <returns><see langword="true"/> when the referenced track path is within a content location of the library; otherwise, <see langword="false"/>.</returns>
|
||||
private bool AreTrackPathsWithinLibraryContentLocations(LibraryEntity library, UpdateTrackCommand command)
|
||||
{
|
||||
return library.ContentLocations.Any(contentLocation => _pathService.IsPathWithin(command.Path!, contentLocation.Path));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the media contributors referenced by <paramref name="command"/>, requiring each referenced Id to already exist.
|
||||
/// </summary>
|
||||
|
||||
-6
@@ -57,12 +57,6 @@ public class UpdateTrackCommandValidator : AbstractValidator<UpdateTrackCommand>
|
||||
.When(command => command.TrackId is not null && command.TrackId.Length > 0)
|
||||
.WithError(Errors.Music.TrackIdCannotBeEmpty);
|
||||
|
||||
RuleFor(command => command.Path)
|
||||
.NotEmpty()
|
||||
.WithError(Errors.Music.TrackPathCannotBeEmpty)
|
||||
.MaximumLength(2048)
|
||||
.WithError(Errors.Music.TrackPathMustBeMaximum2048CharactersLong);
|
||||
|
||||
// Validates the audio metadata of the track: title, lengths, release information, languages, genres and tags.
|
||||
RuleFor(command => command.Metadata)
|
||||
.NotNull()
|
||||
|
||||
Reference in new issue
Block a user