diff --git a/CannedNet/AppConfigs/appsettings.CDN.json b/CannedNet/AppConfigs/appsettings.CDN.json new file mode 100644 index 0000000..4a8e525 --- /dev/null +++ b/CannedNet/AppConfigs/appsettings.CDN.json @@ -0,0 +1,6 @@ +{ + "Hosting": { + "Url": "http://*:5007" + } +} + diff --git a/CannedNet/AppConfigs/appsettings.Image.json b/CannedNet/AppConfigs/appsettings.Image.json new file mode 100644 index 0000000..18f3dcf --- /dev/null +++ b/CannedNet/AppConfigs/appsettings.Image.json @@ -0,0 +1,6 @@ +{ + "Hosting": { + "Url": "http://*:5008" + } +} + diff --git a/CannedNet/Images/gay.png b/CannedNet/Images/gay.png new file mode 100644 index 0000000..f8bbc2c Binary files /dev/null and b/CannedNet/Images/gay.png differ diff --git a/CannedNet/JSON/endpoints.json b/CannedNet/JSON/endpoints.json index d63680e..e605ac5 100644 --- a/CannedNet/JSON/endpoints.json +++ b/CannedNet/JSON/endpoints.json @@ -3,7 +3,7 @@ "API": "https://api.lapis.codes", "WWW": "https://www.lapis.codes", "Notifications": "https://notify.lapis.codes", - "Images": "https://img.lapis.codes", + "Images": "http://localhost:5008", "CDN": "https://cdn.lapis.codes", "Commerce": "https://commerce.lapis.codes", "Matchmaking": "https://match.lapis.codes", diff --git a/CannedNet/JSON/loadingscreentipdata.json b/CannedNet/JSON/loadingscreentipdata.json new file mode 100644 index 0000000..7b7658b --- /dev/null +++ b/CannedNet/JSON/loadingscreentipdata.json @@ -0,0 +1,16 @@ +[ + { + "Name": "bf5d8d41a7184e779399ff45a9e8785a", + "Title": "CannedNet", + "Message": "dude why am i even doing this, this is hell", + "RoomNames": [], + "Context": 0, + "InputType": 0, + "Visibility": 0, + "AllowCycling": false, + "RestrictToNewUsers": false, + "ImageName": "gay", + "PlatformMask": 175, + "CreatedAt": "2019-02-28T18:27:25Z" + } +] \ No newline at end of file diff --git a/CannedNet/JSON/weeklychallenge.json b/CannedNet/JSON/weeklychallenge.json index bf3991d..22a858d 100644 --- a/CannedNet/JSON/weeklychallenge.json +++ b/CannedNet/JSON/weeklychallenge.json @@ -1,64 +1 @@ -{ - "ChallengeMapId": 17, - "CompletedRequired": false, - "StartAt": "2026-03-25T21:00:00", - "EndAt": "2026-04-01T21:00:00", - "ServerTime": "2026-03-31T14:42:54.2754728Z", - "Challenges": [ - { - "ChallengeId": 37, - "Name": "CompleteJT", - "Config": "{\"ct\":0,\"ipc\":false,\"wc\":[{\"ct\":6,\"vs\":[2]},{\"ct\":9,\"vs\":[true],\"v\":\"won\"},{\"ct\":7,\"vs\":[{\"l\":\"acc06e66-c2d0-4361-b0cd-46246a4c455c\"}]}]}", - "Description": "Complete ^TheRiseOfJumbotron quest", - "Tooltip": "Vanquish Jumbotron in the Rise of Jumbotron quest!", - "Complete": false - }, - { - "ChallengeId": 38, - "Name": "CompleteBloodMoon", - "Config": "{\"ct\":0,\"ipc\":false,\"wc\":[{\"ct\":6,\"vs\":[2]},{\"ct\":9,\"vs\":[true],\"v\":\"won\"},{\"ct\":7,\"vs\":[{\"l\":\"49cb8993-a956-43e2-86f4-1318f279b22a\"}]}]}", - "Description": "Complete the ^Crescendo quest", - "Tooltip": "Vanquish Dracula in the Crescendo of the Blood Moon quest!", - "Complete": false - }, - { - "ChallengeId": 44, - "Name": "Complete10PaintballGames", - "Config": "{\"ct\":1,\"ipc\":false,\"ctc\":[{\"ct\":0,\"ipc\":false,\"wc\":[{\"ct\":6,\"vs\":[2]},{\"ct\":7,\"vs\":[{\"l\":\"e122fe98-e7db-49e8-a1b1-105424b6e1f0\"},{\"l\":\"a785267d-c579-42ea-be43-fec1992d1ca7\"},{\"l\":\"ff4c6427-7079-4f59-b22a-69b089420827\"},{\"l\":\"380d18b5-de9c-49f3-80f7-f4a95c1de161\"},{\"l\":\"58763055-2dfb-4814-80b8-16fac5c85709\"},{\"l\":\"65ddbb48-5a01-4e3e-972d-e5c7419e2bc3\"}]}]}],\"t\":10}", - "Description": "Complete 10 games in ^Paintball", - "Tooltip": "Go to ^Paintball and finish 10 games across any maps.", - "Complete": false - }, - { - "ChallengeId": 49, - "Name": "Complete5Charades", - "Config": "{\"ct\":1,\"ipc\":false,\"ctc\":[{\"ct\":0,\"ipc\":false,\"wc\":[{\"ct\":6,\"vs\":[2]},{\"ct\":7,\"vs\":[{\"l\":\"a673712c-877f-4749-b69a-4a4c6310d545\"},{\"l\":\"4078dfed-24bb-4db7-863f-578ba48d726b\"}]}]}],\"t\":5}", - "Description": "Complete 5 Charades games", - "Tooltip": "Finish 5 games in ^3DCharades.", - "Complete": false - }, - { - "ChallengeId": 63, - "Name": "Complete3SpillwayGames", - "Config": "{\"ct\":1,\"ipc\":false,\"ctc\":[{\"ct\":0,\"ipc\":false,\"wc\":[{\"ct\":6,\"vs\":[2]},{\"ct\":7,\"vs\":[{\"l\":\"380d18b5-de9c-49f3-80f7-f4a95c1de161\"}]}]}],\"t\":3}", - "Description": "Complete 3 games of Paintball: Clear Cut", - "Tooltip": "Go to ^Paintball.Clearcut and finish 3 games.", - "Complete": false - } - ], - "Gift": { - "GiftDropId": 3994, - "AvatarItemDesc": "", - "AvatarItemType": 0, - "ConsumableItemDesc": "", - "EquipmentPrefabName": "[ShareCamera]", - "EquipmentModificationGuid": "g5u0weNLmkCLeUXFUVn74Q", - "StorefrontType": 0, - "Xp": 0, - "Level": 0, - "GiftContext": 0, - "GiftRarity": 0 - }, - "FallbackGiftName": "4-Star Box", - "ChallengeThemeString": "\"do like \"kapow\"-like its a punch to the face that we're doing weekly challenges\" - fexlar" -} \ No newline at end of file +{"ChallengeMapId":17,"CompletedRequired":false,"StartAt":"2026-03-25T21:00:00","EndAt":"2026-04-01T21:00:00","ServerTime":"2026-03-31T14:42:54.2754728Z","Challenges":[{"ChallengeId":37,"Name":"CompleteJT","Config":"{\"ct\":0,\"ipc\":false,\"wc\":[{\"ct\":6,\"vs\":[2]},{\"ct\":9,\"vs\":[true],\"v\":\"won\"},{\"ct\":7,\"vs\":[{\"l\":\"acc06e66-c2d0-4361-b0cd-46246a4c455c\"}]}]}","Description":"Complete ^TheRiseOfJumbotron quest","Tooltip":"Vanquish Jumbotron in the Rise of Jumbotron quest!","Complete":false},{"ChallengeId":38,"Name":"CompleteBloodMoon","Config":"{\"ct\":0,\"ipc\":false,\"wc\":[{\"ct\":6,\"vs\":[2]},{\"ct\":9,\"vs\":[true],\"v\":\"won\"},{\"ct\":7,\"vs\":[{\"l\":\"49cb8993-a956-43e2-86f4-1318f279b22a\"}]}]}","Description":"Complete the ^Crescendo quest","Tooltip":"Vanquish Dracula in the Crescendo of the Blood Moon quest!","Complete":false},{"ChallengeId":44,"Name":"Complete10PaintballGames","Config":"{\"ct\":1,\"ipc\":false,\"ctc\":[{\"ct\":0,\"ipc\":false,\"wc\":[{\"ct\":6,\"vs\":[2]},{\"ct\":7,\"vs\":[{\"l\":\"e122fe98-e7db-49e8-a1b1-105424b6e1f0\"},{\"l\":\"a785267d-c579-42ea-be43-fec1992d1ca7\"},{\"l\":\"ff4c6427-7079-4f59-b22a-69b089420827\"},{\"l\":\"380d18b5-de9c-49f3-80f7-f4a95c1de161\"},{\"l\":\"58763055-2dfb-4814-80b8-16fac5c85709\"},{\"l\":\"65ddbb48-5a01-4e3e-972d-e5c7419e2bc3\"}]}]}],\"t\":10}","Description":"Complete 10 games in ^Paintball","Tooltip":"Go to ^Paintball and finish 10 games across any maps.","Complete":false},{"ChallengeId":49,"Name":"Complete5Charades","Config":"{\"ct\":1,\"ipc\":false,\"ctc\":[{\"ct\":0,\"ipc\":false,\"wc\":[{\"ct\":6,\"vs\":[2]},{\"ct\":7,\"vs\":[{\"l\":\"a673712c-877f-4749-b69a-4a4c6310d545\"},{\"l\":\"4078dfed-24bb-4db7-863f-578ba48d726b\"}]}]}],\"t\":5}","Description":"Complete 5 Charades games","Tooltip":"Finish 5 games in ^3DCharades.","Complete":false},{"ChallengeId":63,"Name":"Complete3SpillwayGames","Config":"{\"ct\":1,\"ipc\":false,\"ctc\":[{\"ct\":0,\"ipc\":false,\"wc\":[{\"ct\":6,\"vs\":[2]},{\"ct\":7,\"vs\":[{\"l\":\"380d18b5-de9c-49f3-80f7-f4a95c1de161\"}]}]}],\"t\":3}","Description":"Complete 3 games of Paintball: Clear Cut","Tooltip":"Go to ^Paintball.Clearcut and finish 3 games.","Complete":false}],"Gift":{"GiftDropId":3994,"AvatarItemDesc":"","AvatarItemType":0,"ConsumableItemDesc":"","EquipmentPrefabName":"[ShareCamera]","EquipmentModificationGuid":"g5u0weNLmkCLeUXFUVn74Q","StorefrontType":0,"Xp":0,"Level":0,"GiftContext":0,"GiftRarity":0},"FallbackGiftName":"4-Star Box","ChallengeThemeString":"\"do like \"kapow\"-like its a punch to the face that we're doing weekly challenges\" - fexlar"} \ No newline at end of file diff --git a/CannedNet/Services/APIService.cs b/CannedNet/Services/APIService.cs index 144663a..97bbcf1 100644 --- a/CannedNet/Services/APIService.cs +++ b/CannedNet/Services/APIService.cs @@ -374,17 +374,24 @@ public class APIService app.MapGet("/api/challenge/v2/getCurrent", async (HttpRequest request, AppDbContext db) => { var json = File.ReadAllText("JSON/weeklychallenge.json"); - return Results.Content(json, "application/json"); + //return Results.Content(json, "application/json"); + return "{}"; }); app.MapGet("/roomserver/rooms/createdby/me", async (HttpRequest request, AppDbContext db) => { // TODO ADD FUNCTIONALITY - var json = File.ReadAllText("JSON/weeklychallenge.json"); + var json = File.ReadAllText("JSON/ownedrooms.json"); + return Results.Content(json, "application/json"); + }); + app.MapGet("/roomserver/rooms/{id}", async (HttpRequest request, AppDbContext db, string id) => + { + // TODO ADD FUNCTIONALITY + var json = File.ReadAllText("JSON/ownedrooms.json"); return Results.Content(json, "application/json"); }); app.MapGet("/api/images/v2/named", async (HttpRequest request, AppDbContext db) => { - var json = File.ReadAllText("JSON/weeklychallenge.json"); + var json = File.ReadAllText("JSON/namedimages.json"); return Results.Content(json, "application/json"); }); } diff --git a/CannedNet/Services/CDNService.cs b/CannedNet/Services/CDNService.cs new file mode 100644 index 0000000..9aa814e --- /dev/null +++ b/CannedNet/Services/CDNService.cs @@ -0,0 +1,15 @@ +namespace CannedNet.Services; + +public class CDNService +{ + public WebApplicationBuilder Initialize(string[]? args = null) => ServiceExtensions.CreateRecNetBuilder(args); + + public void MapEndpoints(WebApplication app) + { + app.MapGet("/config/LoadingScreenTipData", (HttpRequest request) => + { + var json = File.ReadAllText("JSON/loadingscreentipdata.json"); + return Results.Content(json, "application/json"); + }); + } +} \ No newline at end of file diff --git a/CannedNet/Services/ImageService.cs b/CannedNet/Services/ImageService.cs new file mode 100644 index 0000000..660cffa --- /dev/null +++ b/CannedNet/Services/ImageService.cs @@ -0,0 +1,43 @@ +namespace CannedNet.Services; + +public class ImageService +{ + public WebApplicationBuilder Initialize(string[]? args = null) => ServiceExtensions.CreateRecNetBuilder(args); + + public void MapEndpoints(WebApplication app) + { + app.MapGet("/{imageId}", (string imageId, HttpContext context) => + { + var imagesDir = "Images"; + + if (!Directory.Exists(imagesDir)) + { + context.Response.StatusCode = 404; + return Task.CompletedTask; + } + + var files = Directory.GetFiles(imagesDir, $"{imageId}.*"); + var filePath = files.FirstOrDefault(); + + if (filePath == null) + { + context.Response.StatusCode = 404; + return Task.CompletedTask; + } + + var extension = Path.GetExtension(filePath).ToLowerInvariant(); + var contentType = extension switch + { + ".png" => "image/png", + ".jpg" or ".jpeg" => "image/jpeg", + ".gif" => "image/gif", + ".webp" => "image/webp", + ".bmp" => "image/bmp", + _ => "application/octet-stream" + }; + + context.Response.ContentType = contentType; + return File.OpenRead(filePath).CopyToAsync(context.Response.Body); + }); + } +} \ No newline at end of file diff --git a/CannedNet/Services/MatchmakingService.cs b/CannedNet/Services/MatchmakingService.cs index 8f936e4..2c23115 100644 --- a/CannedNet/Services/MatchmakingService.cs +++ b/CannedNet/Services/MatchmakingService.cs @@ -52,15 +52,15 @@ public class MatchmakingService location = "76d98498-60a1-430c-ab76-b54a29b7a163", dataBlob = "", eventId = 0, - clubId=0, + clubId = 0, photonRegionId = "us", - photonRoomId = "CannedNet_"+Guid.NewGuid(), - name = "DormRoom", + photonRoomId = Guid.NewGuid(), + name = room, maxCapacity = 4, isFull = false, isPrivate = true, isInProgress = false, - EncryptVoiceChat=false + EncryptVoiceChat = false } }); }); diff --git a/CannedNet/Services/ServiceRegistry.cs b/CannedNet/Services/ServiceRegistry.cs index f1dce8f..4e30b07 100644 --- a/CannedNet/Services/ServiceRegistry.cs +++ b/CannedNet/Services/ServiceRegistry.cs @@ -1,3 +1,5 @@ +using System.Net.Mime; + namespace CannedNet.Services; public class ServiceRegistry @@ -19,6 +21,8 @@ public static class Services new() { Name = "Chat", Port = 5003, ServiceType = typeof(ChatService), ConfigureBuilder = b => b.ConfigureRecNetServices(), MapEndpoints = (app, _) => new ChatService().MapEndpoints(app) }, new() { Name = "Match", Port = 5004, ServiceType = typeof(MatchmakingService), ConfigureBuilder = b => b.ConfigureRecNetServices(), MapEndpoints = (app, _) => new MatchmakingService().MapEndpoints(app) }, new() { Name = "Accounts", Port = 5005, ServiceType = typeof(AccountsService), ConfigureBuilder = b => b.ConfigureRecNetServices(), MapEndpoints = (app, jwt) => new AccountsService().MapEndpoints(app, jwt) }, - new() { Name = "Notify", Port = 5006, ServiceType = typeof(NotifyService), ConfigureBuilder = b => b.ConfigureRecNetServices(), MapEndpoints = (app, _) => new NotifyService().MapEndpoints(app) } + new() { Name = "Notify", Port = 5006, ServiceType = typeof(NotifyService), ConfigureBuilder = b => b.ConfigureRecNetServices(), MapEndpoints = (app, _) => new NotifyService().MapEndpoints(app) }, + new() { Name = "CDN", Port = 5007, ServiceType = typeof(CDNService), ConfigureBuilder = b => b.ConfigureRecNetServices(), MapEndpoints = (app, _) => new CDNService().MapEndpoints(app) }, + new() { Name = "Image", Port = 5008, ServiceType = typeof(ImageService), ConfigureBuilder = b => b.ConfigureRecNetServices(), MapEndpoints = (app, _) => new ImageService().MapEndpoints(app) } ]; }