Recycled files action

This commit is contained in:
2025-07-27 12:30:13 +08:00
parent e7e6c258e2
commit 4c0e0b5ee9
5 changed files with 192 additions and 11 deletions

View File

@@ -7,7 +7,7 @@ namespace DysonNetwork.Drive.Storage;
[ApiController]
[Route("/api/pools")]
public class FilePoolController(AppDatabase db) : ControllerBase
public class FilePoolController(AppDatabase db, FileService fs) : ControllerBase
{
[HttpGet]
[Authorize]
@@ -28,4 +28,19 @@ public class FilePoolController(AppDatabase db) : ControllerBase
return Ok(pools);
}
[Authorize]
[HttpDelete("{id:guid}/recycle")]
public async Task<ActionResult> DeleteFilePoolRecycledFiles(Guid id)
{
if (HttpContext.Items["CurrentUser"] is not Account currentUser) return Unauthorized();
var accountId = Guid.Parse(currentUser.Id);
var pool = await fs.GetPoolAsync(id);
if (pool is null) return NotFound();
if (!currentUser.IsSuperuser && pool.AccountId != accountId) return Unauthorized();
var count = await fs.DeletePoolRecycledFilesAsync(id);
return Ok(new { Count = count });
}
}