a fork of iceshrimp.net but a tweaked frontend to my personal liking. waow
fediverse social-media social iceshrimp fedi
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

[backend/web] Add endpoint for getting Drive status

pancakes 926a1d9c 26179891

+31
+20
Iceshrimp.Backend/Controllers/Web/DriveController.cs
··· 496 496 return new DriveFolderResponse { Id = folder.Id, Name = folder.Name, ParentId = folder.ParentId, }; 497 497 } 498 498 499 + /// <summary> 500 + /// Get status 501 + /// </summary> 502 + /// <remarks>Returns the usage statistics of the user's Drive.</remarks> 503 + /// <response code="200">Drive status</response> 504 + [HttpGet("status")] 505 + [Authenticate] 506 + [Authorize] 507 + [ProducesResults(HttpStatusCode.OK)] 508 + public async Task<DriveStatusResponse> GetDriveStatus() 509 + { 510 + var user = HttpContext.GetUserOrFail(); 511 + 512 + var fileCount = await db.DriveFiles.CountAsync(p => p.User == user && !p.IsLink); 513 + 514 + var usedSize = await db.DriveFiles.Where(p => p.User == user && !p.IsLink).Select(p => (long)p.Size).SumAsync(); 515 + 516 + return new DriveStatusResponse { FileCount = fileCount, UsedSize = usedSize }; 517 + } 518 + 499 519 private async Task<IActionResult> GetFileByAccessKey(string accessKey, string? version, DriveFile? file) 500 520 { 501 521 file ??= await db.DriveFiles.FirstOrDefaultAsync(p => p.AccessKey == accessKey
+11
Iceshrimp.Shared/Schemas/Web/DriveStatusResponse.cs
··· 1 + namespace Iceshrimp.Shared.Schemas.Web; 2 + 3 + public class DriveStatusResponse 4 + { 5 + public required int FileCount { get; set; } 6 + 7 + /// <summary> 8 + /// Sum of the size of every file in the user's Drive in bytes 9 + /// </summary> 10 + public required long UsedSize { get; set; } 11 + }