Mediabibliotheek: prullenbak, delete met tweede bevestiging, laatste gebruik, bestandsnaam (backend)
Continuous Integration / config-sls (pull_request) Successful in 8s
Continuous Integration / changes (pull_request) Successful in 17s
Continuous Integration / config-asf (pull_request) Successful in 9s
Continuous Integration / frontend-prepare (pull_request) Successful in 30s
Continuous Integration / compile-sites (pull_request) Successful in 1m40s
Continuous Integration / frontend-build (pull_request) Successful in 1m9s
Continuous Integration / vulnerability-scan (pull_request) Successful in 1m48s
Continuous Integration / frontend-lint (pull_request) Successful in 41s
Continuous Integration / frontend-test (pull_request) Successful in 2m26s
Continuous Integration / backend-test (pull_request) Canceled after 0s
Continuous Integration / publish-sls-test (pull_request) Canceled after 0s
Continuous Integration / publish-sls-production (pull_request) Canceled after 0s
Continuous Integration / deploy-sls-test (pull_request) Canceled after 0s
Continuous Integration / deploy-sls-production (pull_request) Canceled after 0s
Continuous Integration / publish-asf-test (pull_request) Canceled after 0s
Continuous Integration / deploy-asf-test (pull_request) Canceled after 0s
Continuous Integration / smoke-sls-test (pull_request) Canceled after 0s
Continuous Integration / smoke-asf-test (pull_request) Canceled after 0s
Continuous Integration / backend-build (pull_request) Canceled after 10m10s

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-17 15:08:05 +01:00
co-authored by Claude Sonnet 5.5
parent a6bef57b9c
commit 7263a9a39a
20 changed files with 1271 additions and 42 deletions
@@ -7,21 +7,19 @@ namespace SlpModularCms.Modules.Hero.Services;
/// <summary>
/// Tells the media library which hero images exist and where they are used (one use per slide, with its position in the
/// hero). Read-only: nothing of the hero changes through this class.
/// hero), and moves them to the trash and back for it. The files are removed by <see cref="HeroMediaCleanup"/> after the trash period.
/// </summary>
public class HeroMediaUsageProvider(IHeroRepository repository) : IMediaUsageProvider
public class HeroMediaUsageProvider(IHeroRepository repository, IHeroImageService images) : IMediaUsageProvider
{
public const string SlideKind = "slide";
public string Module => HeroMapping.Area;
public async Task<IReadOnlyList<MediaPhoto>> ListPhotosAsync(CancellationToken cancellationToken)
{
var images = await repository.GetAllImagesReadOnlyAsync(cancellationToken);
return images
.Select(i => new MediaPhoto(Module, i.Id, i.Bytes, i.Width, i.Height, i.CreatedAt, Thumbnail(i)))
.ToList();
}
=> (await repository.GetAllImagesReadOnlyAsync(cancellationToken)).Select(ToPhoto).ToList();
public async Task<IReadOnlyList<MediaPhoto>> ListTrashAsync(CancellationToken cancellationToken)
=> (await repository.GetTrashedImagesReadOnlyAsync(cancellationToken)).Select(ToPhoto).ToList();
public async Task<IReadOnlyList<MediaUse>> ListUsesAsync(IReadOnlyCollection<Guid> photoIds, CancellationToken cancellationToken)
{
@@ -46,6 +44,24 @@ public class HeroMediaUsageProvider(IHeroRepository repository) : IMediaUsagePro
return uses;
}
public async Task<int?> TrashAsync(Guid photoId, Guid callerId, CancellationToken cancellationToken)
{
try
{
return await images.TrashAsync(photoId, callerId, cancellationToken);
}
catch (HeroImageNotFoundException)
{
return null;
}
}
public Task<bool> RestoreAsync(Guid photoId, Guid callerId, CancellationToken cancellationToken)
=> images.RestoreAsync(photoId, callerId, cancellationToken);
private MediaPhoto ToPhoto(HeroImage i)
=> new(Module, i.Id, i.Bytes, i.Width, i.Height, i.CreatedAt, Thumbnail(i), i.OriginalFileName, i.LastUsedAt, i.DeletedAt);
/// <summary>The smallest published WebP of the set; null while the set is not cut yet.</summary>
private static string? Thumbnail(HeroImage image)
{