mirror of
https://github.com/CannedNet/CannedNet.git
synced 2026-10-25 23:18:54 -07:00
incomplete migration to proper controllers
This commit is contained in:
@@ -1,112 +1,109 @@
|
|||||||
using CannedNet;
|
|
||||||
using CannedNet.Data;
|
using CannedNet.Data;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using System.Text.Json.Serialization;
|
|
||||||
using CannedNet.Hubs;
|
|
||||||
using CannedNet.Models;
|
using CannedNet.Models;
|
||||||
using Microsoft.AspNetCore.SignalR;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using CannedNet.Services;
|
|
||||||
using CannedNet.Services.Infrastructure;
|
|
||||||
|
|
||||||
namespace CannedNet.Services.Controllers;
|
namespace CannedNet.Services.Controllers;
|
||||||
|
|
||||||
public class APIController
|
[ApiController, Route("api")]
|
||||||
|
public class APIController : ControllerBase
|
||||||
{
|
{
|
||||||
public WebApplicationBuilder Initialize(string[]? args = null) => ServiceExtensions.CreateRecNetBuilder(args);
|
[HttpGet("config/v1/amplitude")]
|
||||||
|
public async Task<IResult> Amplitude() {
|
||||||
public void MapEndpoints(WebApplication app)
|
return Results.Ok(new {
|
||||||
{
|
|
||||||
var jwtService = app.Services.GetRequiredService<JwtTokenService>();
|
|
||||||
var storefrontService = app.Services.GetRequiredService<StorefrontFillService>();
|
|
||||||
var notificationService = app.Services.GetRequiredService<NotificationService>();
|
|
||||||
|
|
||||||
app.MapGet("/api/config/v1/amplitude", () => Results.Ok(new
|
|
||||||
{
|
|
||||||
AmplitudeKey = "a",
|
AmplitudeKey = "a",
|
||||||
StatSigKey = "a",
|
StatSigKey = "a",
|
||||||
RudderStackKey = "a",
|
RudderStackKey = "a",
|
||||||
UseRudderStack = false
|
UseRudderStack = false
|
||||||
}));
|
});
|
||||||
|
}
|
||||||
|
|
||||||
app.MapGet("/api/config/v1/azurespeech", () => Results.Ok(new
|
[HttpGet("config/v1/azurespeech")]
|
||||||
{
|
public async Task<IResult> AzureSpeech() {
|
||||||
|
return Results.Ok(new {
|
||||||
Key = "dce8de5b297747d9b5bddcc7f19e8c5b",
|
Key = "dce8de5b297747d9b5bddcc7f19e8c5b",
|
||||||
Region = "eastus",
|
Region = "eastus",
|
||||||
Enabled = false
|
Enabled = false
|
||||||
}));
|
});
|
||||||
|
}
|
||||||
|
|
||||||
app.MapPost("/api/gamesight/event", async (HttpRequest request) =>
|
[HttpPost("gamesight/event")]
|
||||||
|
public async Task<IResult> Event(HttpRequest request) {
|
||||||
|
string? eventType = null;
|
||||||
|
string? userId = null;
|
||||||
|
string? identifiers = null;
|
||||||
|
|
||||||
|
if (request.HasFormContentType)
|
||||||
{
|
{
|
||||||
string? eventType = null;
|
IFormCollection form = await request.ReadFormAsync();
|
||||||
string? userId = null;
|
string eventData = form["EventData"].ToString();
|
||||||
string? identifiers = null;
|
|
||||||
|
|
||||||
if (request.HasFormContentType)
|
if (!string.IsNullOrWhiteSpace(eventData))
|
||||||
{
|
{
|
||||||
var form = await request.ReadFormAsync();
|
try
|
||||||
var eventData = form["EventData"].ToString();
|
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(eventData))
|
|
||||||
{
|
{
|
||||||
try
|
using JsonDocument doc = JsonDocument.Parse(eventData);
|
||||||
{
|
JsonElement root = doc.RootElement;
|
||||||
using var doc = JsonDocument.Parse(eventData);
|
|
||||||
var root = doc.RootElement;
|
|
||||||
|
|
||||||
if (root.TryGetProperty("type", out var typeProp))
|
if (root.TryGetProperty("type", out JsonElement typeProp))
|
||||||
eventType = typeProp.GetString();
|
eventType = typeProp.GetString();
|
||||||
|
|
||||||
if (root.TryGetProperty("user_id", out var userIdProp))
|
if (root.TryGetProperty("user_id", out JsonElement userIdProp))
|
||||||
userId = userIdProp.GetString();
|
userId = userIdProp.GetString();
|
||||||
|
|
||||||
if (root.TryGetProperty("transaction_id", out var transactionProp))
|
if (root.TryGetProperty("transaction_id", out JsonElement transactionProp))
|
||||||
identifiers = transactionProp.GetString();
|
identifiers = transactionProp.GetString();
|
||||||
}
|
}
|
||||||
catch (JsonException)
|
catch (JsonException)
|
||||||
{
|
{
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var createdAt = DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ss", System.Globalization.CultureInfo.InvariantCulture);
|
string createdAt = DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ss", System.Globalization.CultureInfo.InvariantCulture);
|
||||||
|
|
||||||
return Results.Json(new
|
return Results.Json(new
|
||||||
|
{
|
||||||
|
@event = new
|
||||||
{
|
{
|
||||||
@event = new
|
created_at = createdAt,
|
||||||
{
|
identifiers = identifiers ?? "",
|
||||||
created_at = createdAt,
|
type = string.IsNullOrWhiteSpace(eventType) ? "game_launch" : eventType,
|
||||||
identifiers = identifiers ?? "",
|
user_id = string.IsNullOrWhiteSpace(userId) ? "0" : userId
|
||||||
type = string.IsNullOrWhiteSpace(eventType) ? "game_launch" : eventType,
|
}
|
||||||
user_id = string.IsNullOrWhiteSpace(userId) ? "0" : userId
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
app.MapGet("/api/config/v2", () => Results.Content(File.ReadAllText("JSON/configv2.json"), "application/json"));
|
[HttpGet("config/v2")]
|
||||||
|
public async Task<IResult> ConfigV2() => Results.Content(await System.IO.File.ReadAllTextAsync("JSON/configv2.json"), "application/json");
|
||||||
|
|
||||||
app.MapGet("/api/versioncheck/v4", () => Results.Ok(new
|
[HttpGet("gameconfigs/v1/all")]
|
||||||
{
|
public async Task<IResult> GameConfigsV1All() => Results.Content(await System.IO.File.ReadAllTextAsync("JSON/gameconfigs.json"), "application/json");
|
||||||
VersionStatus = 0,
|
|
||||||
UpdateNotificationStage = 0,
|
|
||||||
IsVersionIslanded = false,
|
|
||||||
IsCrossPlayDisabled = false
|
|
||||||
}));
|
|
||||||
|
|
||||||
app.MapGet("/api/gameconfigs/v1/all", () => Results.Content(File.ReadAllText("JSON/gameconfigs.json"), "application/json"));
|
[HttpGet("versioncheck/v4")]
|
||||||
|
public async Task<IResult> VersionCheckV4() => Results.Ok(new {
|
||||||
|
VersionStatus = 0,
|
||||||
|
UpdateNotificationStage = 0,
|
||||||
|
IsVersionIslanded = false,
|
||||||
|
IsCrossPlayDisabled = false
|
||||||
|
});
|
||||||
|
|
||||||
app.MapGet("/api/relationships/v2/get", () => Results.Content("[]", "application/json"));
|
[HttpGet("relationships/v2/get")]
|
||||||
app.MapGet("/api/messages/v2/get", () => Results.Content("[]", "application/json"));
|
public async Task<IResult> GetRelationShipsV2() => Results.Content("[]", "application/json");
|
||||||
|
|
||||||
app.MapGet("/api/playerReputation/v1/{id}", (string id) =>
|
[HttpGet("messages/v2/get")]
|
||||||
Results.Content($"{{\"AccountId\":{id},\"Noteriety\":0,\"CheerGeneral\":0,\"CheerHelpful\":0,\"CheerCreative\":0,\"CheerGreatHost\":0,\"CheerSportsman\":0,\"CheerCredit\":20,\"SelectedCheer\":null}}", "application/json"));
|
public async Task<IResult> GetMessagesV2() => Results.Content("[]", "application/json");
|
||||||
|
|
||||||
app.MapGet("/api/players/v1/progression/{id}", (string id) =>
|
[HttpGet("playerReputation/v1/{id}")]
|
||||||
Results.Content($"{{\"PlayerId\":{id},\"Level\":1,\"XP\":0}}", "application/json"));
|
public async Task<IResult> GetPlayersV1Reputation(string id) => Results.Content($"{{\"AccountId\":{id},\"Noteriety\":0,\"CheerGeneral\":0,\"CheerHelpful\":0,\"CheerCreative\":0,\"CheerGreatHost\":0,\"CheerSportsman\":0,\"CheerCredit\":20,\"SelectedCheer\":null}}", "application/json");
|
||||||
|
|
||||||
app.MapPost("/api/playerReputation/v2/bulk", async (HttpRequest httpRequest, AppDbContext db) =>
|
[HttpGet("players/v1/progression/{id}")]
|
||||||
{
|
public async Task<IResult> GetPlayersV1Progression(string id) => Results.Content($"{{\"PlayerId\":{id},\"Level\":1,\"XP\":0}}", "application/json");
|
||||||
/*var ids = await ParseFormIds(httpRequest);
|
|
||||||
|
[HttpPost("playerReputation/v2/bulk")]
|
||||||
|
public async Task<IResult> PostPlayerReputationV2Bulk(HttpRequest httpRequest, AppDbContext db) {
|
||||||
|
/*var ids = await ParseFormIds(httpRequest);
|
||||||
|
|
||||||
if (!ids.Any())
|
if (!ids.Any())
|
||||||
return Results.Json(new List<object>());
|
return Results.Json(new List<object>());
|
||||||
@@ -126,62 +123,59 @@ public class APIController
|
|||||||
|
|
||||||
return Results.Json(reputations);*/
|
return Results.Json(reputations);*/
|
||||||
|
|
||||||
// TODO: implement real endpoint from grabbing from db
|
//TODO: implement real endpoint from grabbing from db
|
||||||
var json = File.ReadAllText("JSON/bulkprogression.json");
|
string json = await System.IO.File.ReadAllTextAsync("JSON/bulkprogression.json");
|
||||||
return Results.Content(json, "application/json");
|
return Results.Content(json, "application/json");
|
||||||
});
|
}
|
||||||
|
|
||||||
app.MapPost("/api/players/v2/progression/bulk", async (HttpRequest httpRequest, AppDbContext db) =>
|
[HttpPost("players/v2/progression/bulk")]
|
||||||
{
|
public async Task<IResult> PostProgressionBulkV2(HttpRequest httpRequest, AppDbContext db) {
|
||||||
var ids = await ParseFormIds(httpRequest);
|
List<int> ids = await ParseFormIds(httpRequest);
|
||||||
|
|
||||||
if (!ids.Any())
|
if (!ids.Any())
|
||||||
return Results.Json(new List<PlayerProgressionBulkResponse>());
|
return Results.Json(new List<PlayerProgressionBulkResponse>());
|
||||||
|
|
||||||
var progressions = await db.PlayerProgressions
|
List<PlayerProgressionBulkResponse> progressions = await db.PlayerProgressions
|
||||||
.Where(p => ids.Contains(p.PlayerId))
|
.Where(p => ids.Contains(p.PlayerId))
|
||||||
.Select(p => new PlayerProgressionBulkResponse { PlayerId = p.PlayerId, Level = p.Level, Xp = p.Xp })
|
.Select(p => new PlayerProgressionBulkResponse { PlayerId = p.PlayerId, Level = p.Level, Xp = p.Xp })
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
return Results.Json(progressions);
|
return Results.Json(progressions);
|
||||||
});
|
}
|
||||||
|
|
||||||
app.MapPost("/api/v1/progression/bulk", async (HttpRequest httpRequest, AppDbContext db) =>
|
[HttpPost("v1/progression/bulk")]
|
||||||
{
|
public async Task<IResult> PostProgressionBulkV1(HttpRequest httpRequest, AppDbContext db) {
|
||||||
var ids = await ParseFormIds(httpRequest);
|
List<int> ids = await ParseFormIds(httpRequest);
|
||||||
|
|
||||||
if (!ids.Any())
|
if (!ids.Any())
|
||||||
return Results.Json(new List<PlayerProgressionBulkResponse>());
|
return Results.Json(new List<PlayerProgressionBulkResponse>());
|
||||||
|
|
||||||
var progressions = await db.PlayerProgressions
|
List<PlayerProgressionBulkResponse> progressions = await db.PlayerProgressions
|
||||||
.Where(p => ids.Contains(p.PlayerId))
|
.Where(p => ids.Contains(p.PlayerId))
|
||||||
.Select(p => new PlayerProgressionBulkResponse { PlayerId = p.PlayerId, Level = p.Level, Xp = p.Xp })
|
.Select(p => new PlayerProgressionBulkResponse { PlayerId = p.PlayerId, Level = p.Level, Xp = p.Xp })
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
return Results.Json(progressions);
|
return Results.Json(progressions);
|
||||||
});
|
}
|
||||||
|
|
||||||
app.MapGet("/api/avatar/v4/items", async (HttpRequest request, AppDbContext db) =>
|
[HttpGet("avatar/v4/items")]
|
||||||
{
|
public async Task<IResult> GetAvatarItemsV4(HttpRequest request, AppDbContext db, JwtTokenService jwtService) {
|
||||||
var authHeader = request.Headers.Authorization.ToString();
|
string authHeader = request.Headers.Authorization.ToString();
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(authHeader) || !authHeader.StartsWith("Bearer ", StringComparison.OrdinalIgnoreCase))
|
if (string.IsNullOrEmpty(authHeader) || !authHeader.StartsWith("Bearer ", StringComparison.OrdinalIgnoreCase))
|
||||||
return Results.Unauthorized();
|
return Results.Unauthorized();
|
||||||
|
|
||||||
var token = authHeader.Substring("Bearer ".Length);
|
string token = authHeader.Substring("Bearer ".Length);
|
||||||
var accountId = jwtService.ValidateAndGetAccountId(token);
|
string? accountId = jwtService.ValidateAndGetAccountId(token);
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(accountId))
|
if (string.IsNullOrEmpty(accountId) || !int.TryParse(accountId.AsSpan(), out int id))
|
||||||
return Results.Unauthorized();
|
return Results.Unauthorized();
|
||||||
|
|
||||||
if (!int.TryParse(accountId.AsSpan(), out var id))
|
List<AvatarItem> ownedItems = await db.AvatarItems
|
||||||
return Results.Unauthorized();
|
|
||||||
|
|
||||||
var ownedItems = await db.AvatarItems
|
|
||||||
.Where(i => i.OwnerAccountId == id)
|
.Where(i => i.OwnerAccountId == id)
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
var defaultItems = new List<object>
|
List<object> defaultItems = new List<object>
|
||||||
{
|
{
|
||||||
new { AvatarItemType = 0, AvatarItemDesc = "5d13a7a2-8213-40e6-90a6-efdd76a3fdcb,,,", PlatformMask = -1, FriendlyName = "Flowing Hair", Tooltip = "", Rarity = 0 },
|
new { AvatarItemType = 0, AvatarItemDesc = "5d13a7a2-8213-40e6-90a6-efdd76a3fdcb,,,", PlatformMask = -1, FriendlyName = "Flowing Hair", Tooltip = "", Rarity = 0 },
|
||||||
new { AvatarItemType = 0, AvatarItemDesc = "1d27b674-f9e2-4ffc-9d8c-a58a1be06457,,,", PlatformMask = -1, FriendlyName = "Afro Hair", Tooltip = "", Rarity = 0 },
|
new { AvatarItemType = 0, AvatarItemDesc = "1d27b674-f9e2-4ffc-9d8c-a58a1be06457,,,", PlatformMask = -1, FriendlyName = "Afro Hair", Tooltip = "", Rarity = 0 },
|
||||||
@@ -338,52 +332,55 @@ public class APIController
|
|||||||
new { AvatarItemType = 0, AvatarItemDesc = "9b5bde11-7408-4798-9fcb-c7ec175444df,,,", PlatformMask = -1, FriendlyName = "Hoop Earrings", Tooltip = "", Rarity = 0 }
|
new { AvatarItemType = 0, AvatarItemDesc = "9b5bde11-7408-4798-9fcb-c7ec175444df,,,", PlatformMask = -1, FriendlyName = "Hoop Earrings", Tooltip = "", Rarity = 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
var allItems = ownedItems.Cast<object>().Concat(defaultItems).ToList();
|
List<object> allItems = ownedItems.Concat(defaultItems).ToList();
|
||||||
|
|
||||||
return Results.Json(allItems);
|
return Results.Json(allItems);
|
||||||
});
|
}
|
||||||
|
|
||||||
app.MapGet("/api/avatar/v2", async (HttpRequest request, AppDbContext db) =>
|
[HttpGet("avatar/v2")]
|
||||||
|
public async Task<IResult> GetAvatarV2(HttpRequest request, AppDbContext db, JwtTokenService jwtService) {
|
||||||
|
string authHeader = request.Headers.Authorization.ToString();
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(authHeader) || !authHeader.StartsWith("Bearer ", StringComparison.OrdinalIgnoreCase))
|
||||||
|
return Results.Unauthorized();
|
||||||
|
|
||||||
|
string token = authHeader.Substring("Bearer ".Length);
|
||||||
|
string? accountId = jwtService.ValidateAndGetAccountId(token);
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(accountId) || !int.TryParse(accountId.AsSpan(), out var id))
|
||||||
|
return Results.Unauthorized();
|
||||||
|
|
||||||
|
PlayerAvatar? avatar = await db.PlayerAvatars.FirstOrDefaultAsync(a => a.OwnerAccountId == id);
|
||||||
|
|
||||||
|
if (avatar == null)
|
||||||
{
|
{
|
||||||
var authHeader = request.Headers.Authorization.ToString();
|
avatar = new PlayerAvatar
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(authHeader) || !authHeader.StartsWith("Bearer ", StringComparison.OrdinalIgnoreCase))
|
|
||||||
return Results.Unauthorized();
|
|
||||||
|
|
||||||
var token = authHeader.Substring("Bearer ".Length);
|
|
||||||
var accountId = jwtService.ValidateAndGetAccountId(token);
|
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(accountId))
|
|
||||||
return Results.Unauthorized();
|
|
||||||
|
|
||||||
if (!int.TryParse(accountId.AsSpan(), out var id))
|
|
||||||
return Results.Unauthorized();
|
|
||||||
|
|
||||||
var avatar = await db.PlayerAvatars
|
|
||||||
.FirstOrDefaultAsync(a => a.OwnerAccountId == id);
|
|
||||||
|
|
||||||
if (avatar == null)
|
|
||||||
{
|
{
|
||||||
avatar = new PlayerAvatar
|
OwnerAccountId = id,
|
||||||
{
|
OutfitSelections = "",
|
||||||
OwnerAccountId = id,
|
FaceFeatures = "{}",
|
||||||
OutfitSelections = "",
|
SkinColor = "",
|
||||||
FaceFeatures = "{}",
|
HairColor = ""
|
||||||
SkinColor = "",
|
};
|
||||||
HairColor = ""
|
db.PlayerAvatars.Add(avatar);
|
||||||
};
|
await db.SaveChangesAsync();
|
||||||
db.PlayerAvatars.Add(avatar);
|
}
|
||||||
await db.SaveChangesAsync();
|
|
||||||
}
|
|
||||||
|
|
||||||
return Results.Json(new
|
return Results.Json(new
|
||||||
{
|
{
|
||||||
OutfitSelections = avatar.OutfitSelections,
|
OutfitSelections = avatar.OutfitSelections,
|
||||||
FaceFeatures = avatar.FaceFeatures,
|
FaceFeatures = avatar.FaceFeatures,
|
||||||
SkinColor = avatar.SkinColor,
|
SkinColor = avatar.SkinColor,
|
||||||
HairColor = avatar.HairColor
|
HairColor = avatar.HairColor
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public void MapEndpoints(WebApplication app) {
|
||||||
|
var jwtService = app.Services.GetRequiredService<JwtTokenService>();
|
||||||
|
var storefrontService = app.Services.GetRequiredService<StorefrontFillService>();
|
||||||
|
var notificationService = app.Services.GetRequiredService<NotificationService>();
|
||||||
|
|
||||||
app.MapPost("/api/avatar/v2/set", async (HttpRequest request, AppDbContext db) =>
|
app.MapPost("/api/avatar/v2/set", async (HttpRequest request, AppDbContext db) =>
|
||||||
{
|
{
|
||||||
@@ -430,7 +427,7 @@ public class APIController
|
|||||||
|
|
||||||
app.MapGet("/api/PlayerReporting/v1/voteToKickReasons", async (HttpRequest request, AppDbContext db) =>
|
app.MapGet("/api/PlayerReporting/v1/voteToKickReasons", async (HttpRequest request, AppDbContext db) =>
|
||||||
{
|
{
|
||||||
var json = File.ReadAllText("JSON/vtkreasons.json");
|
var json = System.IO.File.ReadAllText("JSON/vtkreasons.json");
|
||||||
return Results.Content(json, "application/json");
|
return Results.Content(json, "application/json");
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -556,12 +553,12 @@ public class APIController
|
|||||||
app.MapGet("/api/objectives/v1/myprogress", async (HttpRequest request, AppDbContext db) =>
|
app.MapGet("/api/objectives/v1/myprogress", async (HttpRequest request, AppDbContext db) =>
|
||||||
{
|
{
|
||||||
// TODO ADD FUNCTIONALITY
|
// TODO ADD FUNCTIONALITY
|
||||||
var json = File.ReadAllText("JSON/tempmyprogress.json");
|
var json = System.IO.File.ReadAllText("JSON/tempmyprogress.json");
|
||||||
return Results.Content(json, "application/json");
|
return Results.Content(json, "application/json");
|
||||||
});
|
});
|
||||||
app.MapGet("/api/communityboard/v2/current", async (HttpRequest request, AppDbContext db) =>
|
app.MapGet("/api/communityboard/v2/current", async (HttpRequest request, AppDbContext db) =>
|
||||||
{
|
{
|
||||||
var json = File.ReadAllText("JSON/communityboard.json");
|
var json = System.IO.File.ReadAllText("JSON/communityboard.json");
|
||||||
return Results.Content(json, "application/json");
|
return Results.Content(json, "application/json");
|
||||||
});
|
});
|
||||||
app.MapGet("/api/playerevents/v1/all", async (HttpRequest request, AppDbContext db) =>
|
app.MapGet("/api/playerevents/v1/all", async (HttpRequest request, AppDbContext db) =>
|
||||||
@@ -575,7 +572,7 @@ public class APIController
|
|||||||
});
|
});
|
||||||
app.MapGet("/api/announcement/v1/get", async (HttpRequest request, AppDbContext db) =>
|
app.MapGet("/api/announcement/v1/get", async (HttpRequest request, AppDbContext db) =>
|
||||||
{
|
{
|
||||||
var json = File.ReadAllText("JSON/announcements.json");
|
var json = System.IO.File.ReadAllText("JSON/announcements.json");
|
||||||
return Results.Content(json, "application/json");
|
return Results.Content(json, "application/json");
|
||||||
});
|
});
|
||||||
app.MapGet("/api/quickPlay/v1/getandclear", async (HttpRequest request, AppDbContext db) =>
|
app.MapGet("/api/quickPlay/v1/getandclear", async (HttpRequest request, AppDbContext db) =>
|
||||||
@@ -1041,7 +1038,7 @@ public class APIController
|
|||||||
});
|
});
|
||||||
app.MapGet("/api/images/v2/named", async (HttpRequest request, AppDbContext db) =>
|
app.MapGet("/api/images/v2/named", async (HttpRequest request, AppDbContext db) =>
|
||||||
{
|
{
|
||||||
var json = File.ReadAllText("JSON/namedimages.json");
|
var json = System.IO.File.ReadAllText("JSON/namedimages.json");
|
||||||
return Results.Content(json, "application/json");
|
return Results.Content(json, "application/json");
|
||||||
});
|
});
|
||||||
app.MapPost("/api/objectives/v1/updateobjective", async (HttpRequest request, AppDbContext db) =>
|
app.MapPost("/api/objectives/v1/updateobjective", async (HttpRequest request, AppDbContext db) =>
|
||||||
@@ -1060,7 +1057,7 @@ public class APIController
|
|||||||
var storefront = storefronts.FirstOrDefault(s => s.StorefrontType == 300 && s.Name == "rc_cafe_storefront");
|
var storefront = storefronts.FirstOrDefault(s => s.StorefrontType == 300 && s.Name == "rc_cafe_storefront");
|
||||||
if (storefront == null)
|
if (storefront == null)
|
||||||
{
|
{
|
||||||
var json = File.ReadAllText("JSON/cafestorefront.json");
|
var json = System.IO.File.ReadAllText("JSON/cafestorefront.json");
|
||||||
return Results.Content(json, "application/json");
|
return Results.Content(json, "application/json");
|
||||||
}
|
}
|
||||||
var storeItems = storefront.Items.Select(item => new
|
var storeItems = storefront.Items.Select(item => new
|
||||||
@@ -1111,7 +1108,7 @@ public class APIController
|
|||||||
var storefront = storefronts.FirstOrDefault(s => s.StorefrontType == 2 && s.Name == "rec_center_store");
|
var storefront = storefronts.FirstOrDefault(s => s.StorefrontType == 2 && s.Name == "rec_center_store");
|
||||||
if (storefront == null)
|
if (storefront == null)
|
||||||
{
|
{
|
||||||
var json = File.ReadAllText("JSON/storefront12.json");
|
var json = System.IO.File.ReadAllText("JSON/storefront12.json");
|
||||||
return Results.Content(json, "application/json");
|
return Results.Content(json, "application/json");
|
||||||
}
|
}
|
||||||
var storeItems = storefront.Items.Select(item => new
|
var storeItems = storefront.Items.Select(item => new
|
||||||
@@ -1608,7 +1605,7 @@ public class APIController
|
|||||||
});
|
});
|
||||||
app.MapGet("/api/rooms/v1/filters", async (HttpRequest request, AppDbContext db) =>
|
app.MapGet("/api/rooms/v1/filters", async (HttpRequest request, AppDbContext db) =>
|
||||||
{
|
{
|
||||||
var json = File.ReadAllText("JSON/roomfilters.json");
|
var json = System.IO.File.ReadAllText("JSON/roomfilters.json");
|
||||||
return Results.Content(json, "application/json");
|
return Results.Content(json, "application/json");
|
||||||
});
|
});
|
||||||
app.MapGet("/roomserver/rooms/{id}/interactionby/me", async (HttpRequest request, AppDbContext db, string id) =>
|
app.MapGet("/roomserver/rooms/{id}/interactionby/me", async (HttpRequest request, AppDbContext db, string id) =>
|
||||||
@@ -1640,7 +1637,7 @@ public class APIController
|
|||||||
var savedFileName = imageId + extension;
|
var savedFileName = imageId + extension;
|
||||||
var filePath = Path.Combine(ImagesDir, savedFileName);
|
var filePath = Path.Combine(ImagesDir, savedFileName);
|
||||||
|
|
||||||
using (var fileStream = File.Create(filePath))
|
using (var fileStream = System.IO.File.Create(filePath))
|
||||||
{
|
{
|
||||||
await file.CopyToAsync(fileStream);
|
await file.CopyToAsync(fileStream);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user