diff --git a/Iceshrimp.Backend/Controllers/Web/DriveController.cs b/Iceshrimp.Backend/Controllers/Web/DriveController.cs index 7503e577..99c6d661 100644 --- a/Iceshrimp.Backend/Controllers/Web/DriveController.cs +++ b/Iceshrimp.Backend/Controllers/Web/DriveController.cs @@ -120,6 +120,30 @@ public class DriveController( }; } + [HttpGet("/by-hash/{sha256}")] + [Authenticate] + [Authorize] + [Produces(MediaTypeNames.Application.Json)] + [ProducesResults(HttpStatusCode.OK)] + [ProducesErrors(HttpStatusCode.NotFound)] + public async Task GetFileByHash(string sha256) + { + var user = HttpContext.GetUserOrFail(); + var file = await db.DriveFiles.FirstOrDefaultAsync(p => p.User == user && p.Sha256 == sha256) ?? + throw GracefulException.NotFound("File not found"); + + return new DriveFileResponse + { + Id = file.Id, + Url = file.AccessUrl, + ThumbnailUrl = file.ThumbnailAccessUrl, + Filename = file.Name, + ContentType = file.Type, + Description = file.Comment, + Sensitive = file.IsSensitive + }; + } + [HttpPatch("{id}")] [Authenticate] [Authorize]