Implement media storage and processing features: update configuration in .env.example and appsettings files, enhance Docker setup for media storage, and add media-related services and database entities. Include ffmpeg for media handling and adjust Kestrel settings for large file uploads.
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
using LiteCqrs;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using TeleWave.Application.Common.Interfaces;
|
||||
using TeleWave.Application.Common.Models;
|
||||
|
||||
namespace TeleWave.Application.Media.Delete;
|
||||
|
||||
public sealed class DeleteMediaAssetCommandHandler(IAppDbContext dbContext, IMediaStorage storage)
|
||||
: ICommandHandler<DeleteMediaAssetCommand, Result>
|
||||
{
|
||||
public async Task<Result> Handle(
|
||||
DeleteMediaAssetCommand command,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var asset = await dbContext.MediaAssets.FirstOrDefaultAsync(
|
||||
x => x.Id == command.Id,
|
||||
cancellationToken
|
||||
);
|
||||
if (asset is null)
|
||||
return Result.Failure(MediaErrors.NotFound);
|
||||
|
||||
// TODO(этап 2): запретить удаление, пока ассет используется в расписании/пуле канала.
|
||||
storage.DeleteAssetArtifacts(asset.Id, asset.OriginalExtension);
|
||||
dbContext.MediaAssets.Remove(asset);
|
||||
|
||||
return Result.Success();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user