mirror of https://github.com/ErsatzTV/ErsatzTV.git
2 changed files with 25 additions and 6 deletions
@ -1,20 +1,34 @@ |
|||||||
using ErsatzTV.Application.Maintenance; |
using ErsatzTV.Application.Maintenance; |
||||||
|
using ErsatzTV.Core; |
||||||
using MediatR; |
using MediatR; |
||||||
using Microsoft.AspNetCore.Mvc; |
using Microsoft.AspNetCore.Mvc; |
||||||
|
|
||||||
namespace ErsatzTV.Controllers.Api; |
namespace ErsatzTV.Controllers.Api; |
||||||
|
|
||||||
[ApiController] |
[ApiController] |
||||||
public class MaintenanceController |
public class MaintenanceController(IMediator mediator) |
||||||
{ |
{ |
||||||
private readonly IMediator _mediator; |
|
||||||
|
|
||||||
public MaintenanceController(IMediator mediator) => _mediator = mediator; |
|
||||||
|
|
||||||
[HttpGet("/api/maintenance/gc")] |
[HttpGet("/api/maintenance/gc")] |
||||||
public async Task<IActionResult> GarbageCollection([FromQuery] bool force = false) |
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(); |
return new OkResult(); |
||||||
} |
} |
||||||
} |
} |
||||||
|
Loading…
Reference in new issue