✨ FIle detail page
This commit is contained in:
@@ -30,11 +30,15 @@ public class FilePool : ModelBase, IIdentifiedResource
|
||||
[MaxLength(1024)] public string Name { get; set; } = string.Empty;
|
||||
[Column(TypeName = "jsonb")] public RemoteStorageConfig StorageConfig { get; set; } = new();
|
||||
[Column(TypeName = "jsonb")] public BillingConfig BillingConfig { get; set; } = new();
|
||||
public bool PublicIndexable { get; set; } = false;
|
||||
public bool PublicUsable { get; set; } = false;
|
||||
public bool NoOptimization { get; set; } = false;
|
||||
public bool NoMetadata { get; set; } = false;
|
||||
public bool AllowEncryption { get; set; } = true;
|
||||
public bool AllowAnonymous { get; set; } = true;
|
||||
public int RequirePrivilege { get; set; } = 0;
|
||||
|
||||
public Guid? AccountId { get; set; }
|
||||
|
||||
public string ResourceIdentifier => $"file-pool/{Id}";
|
||||
}
|
25
DysonNetwork.Drive/Storage/FilePoolController.cs
Normal file
25
DysonNetwork.Drive/Storage/FilePoolController.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using DysonNetwork.Shared.Proto;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace DysonNetwork.Drive.Storage;
|
||||
|
||||
[ApiController]
|
||||
[Route("/api/pools")]
|
||||
public class FilePoolController(AppDatabase db) : ControllerBase
|
||||
{
|
||||
[HttpGet]
|
||||
[Authorize]
|
||||
public async Task<ActionResult<List<FilePool>>> ListUsablePools()
|
||||
{
|
||||
if (HttpContext.Items["CurrentUser"] is not Account currentUser) return Unauthorized();
|
||||
|
||||
var accountId = Guid.Parse(currentUser.Id);
|
||||
var pools = await db.Pools
|
||||
.Where(p => p.PublicUsable || p.AccountId == accountId)
|
||||
.ToListAsync();
|
||||
|
||||
return Ok(pools);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user