diff --git a/CannedNet/Services/Controllers/EconController.cs b/CannedNet/Services/Controllers/EconController.cs index 7ed7258..c4d9ba9 100644 --- a/CannedNet/Services/Controllers/EconController.cs +++ b/CannedNet/Services/Controllers/EconController.cs @@ -238,7 +238,29 @@ public class EconController : ControllerBase [HttpGet("api/avatar/v1/defaultbaseavataritems")] public async Task DefaultBaseAvatarItems() { - var json = System.IO.File.ReadAllText("JSON/defaultAvatarItems.json"); - return Results.Content(json, "application/json"); + return Results.Ok(new List()); + } + + [Authorize] + [HttpGet("econ/customAvatarItems/v1/owned")] + public async Task GetMyOwnedCustomAvatarItems(int skip, int take) + { + return Results.Ok(new + { + Results = Array.Empty(), + TotalResults = 0 + }); + } + + [HttpGet("api/roomcurrencies/v1/currencies")] + public async Task GetRoomCurrencies() + { + return Results.Ok(new List()); + } + + [HttpGet("api/roomconsumables/v1/roomConsumable/room/{roomId}")] + public async Task GetRoomConsumablesForRoom(long roomId) + { + return Results.Ok(new List()); } } diff --git a/CannedNet/Services/Controllers/ImageController.cs b/CannedNet/Services/Controllers/ImageController.cs index a6d5f0b..ae16848 100644 --- a/CannedNet/Services/Controllers/ImageController.cs +++ b/CannedNet/Services/Controllers/ImageController.cs @@ -12,7 +12,8 @@ public class ImageController : ControllerBase { private static readonly byte[] PlaceholderJpeg; - static ImageController() { + static ImageController() + { Signatures.Init(); using Image image = new(64, 64); @@ -23,7 +24,9 @@ public class ImageController : ControllerBase } [HttpGet("{imageName}")] - public async Task GetImage(HttpContext context, string imageName) { + public async Task GetImage(string imageName) + { + HttpContext context = HttpContext; string imagesDir = Path.Combine("Images"); Directory.CreateDirectory(imagesDir); string filePath = Path.Combine(imagesDir, imageName); @@ -31,10 +34,12 @@ public class ImageController : ControllerBase byte[] imageBytes; string contentType; - if (System.IO.File.Exists(filePath)) { + if (System.IO.File.Exists(filePath)) + { imageBytes = await System.IO.File.ReadAllBytesAsync(filePath); string ext = Path.GetExtension(imageName).ToLowerInvariant(); - contentType = ext switch { + contentType = ext switch + { ".jpg" or ".jpeg" => "image/jpeg", ".gif" => "image/gif", ".webp" => "image/webp", @@ -42,7 +47,8 @@ public class ImageController : ControllerBase _ => "image/png" }; } - else { + else + { imageBytes = PlaceholderJpeg; contentType = "image/jpeg"; } @@ -51,7 +57,8 @@ public class ImageController : ControllerBase string? widthStr = context.Request.Query["width"].FirstOrDefault(); string? heightStr = context.Request.Query["height"].FirstOrDefault(); - if (string.IsNullOrEmpty(widthStr) && string.IsNullOrEmpty(heightStr) && string.IsNullOrEmpty(cropSquare)) { + if (string.IsNullOrEmpty(widthStr) && string.IsNullOrEmpty(heightStr) && string.IsNullOrEmpty(cropSquare)) + { SignImageResponse(context, ref imageBytes); return Results.File(imageBytes, contentType); } @@ -61,7 +68,8 @@ public class ImageController : ControllerBase int resizeWidth = 0; int resizeHeight = 0; - if (!string.IsNullOrEmpty(cropSquare) && cropSquare != "0" && cropSquare != "false") { + if (!string.IsNullOrEmpty(cropSquare) && cropSquare != "0" && cropSquare != "false") + { int size = Math.Min(image.Width, image.Height); int x = (image.Width - size) / 2; int y = (image.Height - size) / 2; @@ -74,7 +82,8 @@ public class ImageController : ControllerBase if (int.TryParse(heightStr, out int h)) resizeHeight = h; - if (resizeWidth > 0 || resizeHeight > 0) { + if (resizeWidth > 0 || resizeHeight > 0) + { image.Mutate(x => x.Resize(resizeWidth, resizeHeight)); } @@ -85,12 +94,14 @@ public class ImageController : ControllerBase return Results.File(imageBytes, "image/jpeg"); } - private static void SignImageResponse(HttpContext context, ref byte[] imageBytes) { + private static void SignImageResponse(HttpContext context, ref byte[] imageBytes) + { if (context.Request.Query["sig"] != "p1") return; string? signature = Signatures.Sign(imageBytes); - if (signature != null) { + if (signature != null) + { context.Response.Headers["Content-Signature"] = $"key-id=KEY:RSA:p1.rec.net; data={signature}"; } } -} \ No newline at end of file +}