Add torrent client integration and downloads management: introduce qbittorrent service in Docker setup, implement downloads endpoint in API, and enhance media storage to handle imported files. Update frontend routes and translations for downloads management.

This commit is contained in:
Leonid Pershin
2026-07-24 16:42:14 +03:00
parent 5853009d71
commit e7840ba919
18 changed files with 382 additions and 6 deletions
@@ -0,0 +1,52 @@
using LiteCqrs;
using TeleWave.Api.Common;
using TeleWave.Application.Common.Interfaces;
using TeleWave.Application.Media.Downloads;
using TeleWave.Application.Media.Register;
using TeleWave.Domain.Media;
using TeleWave.Infrastructure.Identity;
namespace TeleWave.Api.Endpoints;
public static class DownloadsEndpoints
{
public static IEndpointRouteBuilder MapDownloadsEndpoints(this IEndpointRouteBuilder app)
{
var admin = app.MapGroup("/api/admin/downloads")
.WithTags("Admin.Downloads")
.RequireAuthorization(policy => policy.RequireRole(RoleNames.Admin));
admin.MapGet("", List).Produces<IReadOnlyList<DownloadFileDto>>();
admin.MapPost("/import", Import).Produces<CreatedIdResponse>(StatusCodes.Status201Created);
return app;
}
private static async Task<IResult> List(ISender sender, CancellationToken cancellationToken)
{
var result = await sender.Send(new ListDownloadsQuery(), cancellationToken);
return Results.Ok(result);
}
/// <summary>Импорт выбранного файла из downloads/: регистрирует ассет (копией) и ставит в обработку.</summary>
private static async Task<IResult> Import(
ImportDownloadBody body,
ISender sender,
IMediaProcessingQueue queue,
CancellationToken cancellationToken
)
{
var fileName = Path.GetFileName(body.RelativePath);
var result = await sender.Send(
new RegisterMediaAssetCommand(body.RelativePath, MediaSource.Download, fileName),
cancellationToken
);
if (!result.IsSuccess)
return result.ToHttpResult();
queue.Enqueue(result.Value);
return Results.Created($"/api/admin/media/{result.Value}", new CreatedIdResponse(result.Value));
}
}
public sealed record ImportDownloadBody(string RelativePath);
+1
View File
@@ -113,6 +113,7 @@ app.MapAuthEndpoints();
app.MapRoleEndpoints();
app.MapAdminUserEndpoints();
app.MapMediaEndpoints();
app.MapDownloadsEndpoints();
app.MapShowEndpoints();
app.MapChannelEndpoints();
app.MapStreamingEndpoints();