Refactor media storage and management functionalities: enhance IMediaStorage interface with manual inbox handling, update FileSystemMediaStorage to support manual file imports, and improve MediaPathResolver for better path management. Extend MediaEndpoints to include new manual inbox features and update frontend components for improved media management experience.
build / backend (push) Successful in 2m8s
build / frontend (push) Successful in 36s
tests / backend-tests (push) Successful in 1m35s

This commit is contained in:
Leonid Pershin
2026-07-26 15:16:55 +03:00
parent 2445ba56b5
commit b602d099ca
16 changed files with 1750 additions and 1039 deletions
@@ -0,0 +1,47 @@
using LiteCqrs;
using Microsoft.EntityFrameworkCore;
using TeleWave.Application.Common.Interfaces;
using TeleWave.Domain.Media;
namespace TeleWave.Application.Media.ManualInbox;
public sealed class ListManualInboxQueryHandler(IAppDbContext dbContext, IMediaStorage storage)
: IQueryHandler<ListManualInboxQuery, ManualInboxListDto>
{
/// <summary>Потолок выдачи: каталог наполняет человек, и он может оказаться огромным.</summary>
private const int MaxFiles = 500;
public async Task<ManualInboxListDto> Handle(
ListManualInboxQuery query,
CancellationToken cancellationToken
)
{
// Просим на один больше лимита — так видно, что каталог не поместился целиком.
var files = storage.ListManualInbox(MaxFiles + 1);
var truncated = files.Count > MaxFiles;
var page = truncated ? files.Take(MaxFiles).ToList() : files;
if (page.Count == 0)
return new ManualInboxListDto([], false);
// Дедуп — по имени файла, тем же правилом, что и при регистрации ассета.
var names = page.Select(f => f.Name).Distinct().ToList();
var taken = await dbContext
.MediaAssets.AsNoTracking()
.Where(a => names.Contains(a.OriginalFileName) && a.Status != MediaAssetStatus.Failed)
.Select(a => a.OriginalFileName)
.ToListAsync(cancellationToken);
var takenSet = taken.ToHashSet(StringComparer.Ordinal);
return new ManualInboxListDto(
page.Select(f => new ManualInboxFileDto(
f.RelativePath,
f.Name,
f.SizeBytes,
MediaFormats.IsAllowed(f.Name),
takenSet.Contains(f.Name)
))
.ToList(),
truncated
);
}
}