add api endpoint to empty trash (#1988)

This commit is contained in:
Jason Dove
2025-04-06 14:26:40 +00:00
committed by GitHub
parent f0d5200843
commit 100ae0adda
2 changed files with 25 additions and 6 deletions
+5
View File
@@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## [Unreleased]
### Added
- Add `linux-musl-x64` artifact for users running Alpine x64
- Add API endpoint to empty trash (POST to `/api/maintenance/empty_trash`)
- e.g. `curl -XPOST -d '' http://localhost:8409/api/maintenance/empty_trash`
### Fixed
- Fix error message about synchronizing Plex collections from a Plex server that has zero collections
@@ -1,20 +1,34 @@
using ErsatzTV.Application.Maintenance;
using ErsatzTV.Core;
using MediatR;
using Microsoft.AspNetCore.Mvc;
namespace ErsatzTV.Controllers.Api;
[ApiController]
public class MaintenanceController
public class MaintenanceController(IMediator mediator)
{
private readonly IMediator _mediator;
public MaintenanceController(IMediator mediator) => _mediator = mediator;
[HttpGet("/api/maintenance/gc")]
public async Task<IActionResult> GarbageCollection([FromQuery] bool force = false)
{
await _mediator.Send(new ReleaseMemory(force));
await mediator.Send(new ReleaseMemory(force));
return new OkResult();
}
[HttpPost("/api/maintenance/empty_trash")]
public async Task<IActionResult> EmptyTrash()
{
Either<BaseError, Unit> result = await mediator.Send(new EmptyTrash());
foreach (BaseError error in result.LeftToSeq())
{
return new ContentResult
{
StatusCode = StatusCodes.Status500InternalServerError,
Content = error.ToString(),
ContentType = "text/plain"
};
}
return new OkResult();
}
}