Albums previously had no cover concept at all: no picture upload
flow, no GET /albums/{id}/cover, and AlbumApplicationResponse's
image-key fields were plumbed but never populated. Description,
Pictures and TrackCount already lived on the shared Album base entity
for both local and external albums, so unifying the cover story only
required building the missing local-album picture pipeline.
Backend, cloning PlayList's existing async picture-processing
architecture exactly (MassTransit routing slip + saga), but making
the picture mandatory instead of optional (matching Track's pattern):
- AlbumPictures moves from all-nullable to required fields.
- New AlbumConfiguration (routes/sizes), deliberately without
PlayList's preset-picture fallback since a picture is now required
up front.
- CreateAlbum now takes a mandatory PictureIntentId, validates and
consumes the upload intent, and kicks off the same
copy-to-final -> resize -> upload -> update-entity routing slip
PlayLists use, via a new AlbumProcessingState saga that marks the
album Failed on a picture-processing failure.
- UpdateAlbum takes an optional NewPictureIntentId to replace the
cover later.
- New GET /albums/{id}/cover and POST /albums/upload-picture
endpoints, mirroring the playlist ones.
- New EF migration for the AlbumProcessingState saga table.
Frontend:
- AlbumForm gains a cover dropzone, required on create and optional
on edit (via ImageDropzone's new `required` prop), uploaded through
the same presigned-upload helper playlists use.
- New /api/albums/{id}/cover proxy route.
- PlaylistArt gains a generic coverUrl prop so AlbumHeader and the
album list/detail cards render the real uploaded cover instead of
only the track mosaic fallback.
Delete-time picture cleanup for albums is intentionally left as a
follow-up, matching the existing gap in playlist deletion.
80 lines
2.9 KiB
C#
80 lines
2.9 KiB
C#
using System.ComponentModel.DataAnnotations;
|
|
using Musify.Application.Shared;
|
|
|
|
namespace Musify.Application.Configuration
|
|
{
|
|
public class AlbumConfiguration
|
|
{
|
|
public const string SectionName = "Album";
|
|
|
|
[Required]
|
|
public AlbumRoutes Routes { get; set; } = new AlbumRoutes();
|
|
|
|
[Required]
|
|
public AlbumPicturesSizes PicturesSizes { get; set; } = new AlbumPicturesSizes();
|
|
}
|
|
|
|
public class AlbumRoutes
|
|
{
|
|
[Required]
|
|
public string UploadsFolder { get; set; } = "uploads";
|
|
|
|
[Required]
|
|
public string ParentFolders { get; set; } = "Albums";
|
|
|
|
[Required]
|
|
public string OriginalPicturesFolder { get; set; } = "OriginalPictures";
|
|
|
|
[Required]
|
|
public string SmallPicturesFolder { get; set; } = "SmallPictures";
|
|
|
|
[Required]
|
|
public string MediumPicturesFolder { get; set; } = "MediumPictures";
|
|
|
|
[Required]
|
|
public string LargePicturesFolder { get; set; } = "LargePictures";
|
|
|
|
public string SmallPicturesPath => StorageKey.Combine(ParentFolders, SmallPicturesFolder);
|
|
|
|
public string MediumPicturesPath => StorageKey.Combine(ParentFolders, MediumPicturesFolder);
|
|
|
|
public string LargePicturesPath => StorageKey.Combine(ParentFolders, LargePicturesFolder);
|
|
|
|
public string OriginalPicturesPath => StorageKey.Combine(ParentFolders, OriginalPicturesFolder);
|
|
|
|
public string BuildOriginalPicturePath(string pictureName) => StorageKey.Combine(ParentFolders, OriginalPicturesFolder, pictureName);
|
|
|
|
public string BuildOriginalPicturePath(long userId, string pictureName) => StorageKey.Combine(UploadsFolder, userId.ToString(), ParentFolders, OriginalPicturesFolder, pictureName);
|
|
|
|
public string BuildSmallPicturePath(string pictureName) => StorageKey.Combine(ParentFolders, SmallPicturesFolder, pictureName);
|
|
|
|
public string BuildMediumPicturePath(string pictureName) => StorageKey.Combine(ParentFolders, MediumPicturesFolder, pictureName);
|
|
|
|
public string BuildLargePicturePath(string pictureName) => StorageKey.Combine(ParentFolders, LargePicturesFolder, pictureName);
|
|
|
|
public string BuildTempPicturePath(string tempRootPrefix, long userId, string objectName) =>
|
|
StorageKey.Combine(tempRootPrefix, userId.ToString(), ParentFolders, objectName);
|
|
}
|
|
|
|
public class AlbumPicturesSizes
|
|
{
|
|
[Range(1, 1024)]
|
|
public int SmallPictureWidth { get; set; } = 128;
|
|
|
|
[Range(1, 1024)]
|
|
public int SmallPictureHeight { get; set; } = 128;
|
|
|
|
[Range(1, 1024)]
|
|
public int MediumPictureWidth { get; set; } = 256;
|
|
|
|
[Range(1, 1024)]
|
|
public int MediumPictureHeight { get; set; } = 256;
|
|
|
|
[Range(1, 1024)]
|
|
public int LargePictureWidth { get; set; } = 512;
|
|
|
|
[Range(1, 1024)]
|
|
public int LargePictureHeight { get; set; } = 512;
|
|
}
|
|
}
|