✨ Recycled files action
This commit is contained in:
@@ -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 });
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user