Refactor bumper template background management: rename background upload endpoint to reflect new functionality, update related command and handler to use image ID instead of extension, and adjust data models to support image references. Remove obsolete background handling code and enhance UI components for improved image selection and display.

This commit is contained in:
Leonid Pershin
2026-07-25 11:56:36 +03:00
parent a970eae7d2
commit 7efd616c29
35 changed files with 1227 additions and 279 deletions
@@ -1,5 +1,4 @@
using LiteCqrs;
using Microsoft.EntityFrameworkCore;
using TeleWave.Api.Common;
using TeleWave.Application.Common.Interfaces;
using TeleWave.Application.Images.DeleteImage;
@@ -48,12 +47,7 @@ public static class MetadataEndpoints
.Produces(StatusCodes.Status204NoContent);
admin.MapPost("/shows/{showId:guid}/refresh-episodes", RefreshEpisodes).Produces<int>();
// Кадры серий отдаём публично (просто картинки, id не угадать) — чтобы работал <img src>.
// Постеры шоу теперь в общем реестре и отдаются по /api/images/{id}.
app.MapGet("/api/metadata/episodes/{episodeId:guid}/still", ServeStill)
.WithTags("Metadata")
.Produces(StatusCodes.Status200OK);
// Постеры шоу и кадры серий теперь в общем реестре и отдаются по /api/images/{id}.
return app;
}
@@ -181,37 +175,6 @@ public static class MetadataEndpoints
);
return result.ToHttpResult();
}
private static async Task<IResult> ServeStill(
Guid episodeId,
IAppDbContext dbContext,
IMetadataImageStore imageStore,
CancellationToken cancellationToken
)
{
var path = await dbContext.Shows.AsNoTracking()
.SelectMany(s => s.Episodes)
.Where(e => e.Id == episodeId)
.Select(e => e.StillPath)
.FirstOrDefaultAsync(cancellationToken);
return ServeImage(path, imageStore);
}
private static IResult ServeImage(string? relativePath, IMetadataImageStore imageStore)
{
if (string.IsNullOrEmpty(relativePath))
return Results.NotFound();
var abs = imageStore.ResolveAbsolutePath(relativePath);
return abs is null ? Results.NotFound() : Results.File(abs, ContentTypeFor(Path.GetExtension(abs)));
}
private static string ContentTypeFor(string extension) =>
extension.ToLowerInvariant() switch
{
".png" => "image/png",
".webp" => "image/webp",
_ => "image/jpeg",
};
}
public sealed record ApplyMetadataBody(string Provider, string ExternalId);