mirror of
https://github.com/CannedNet/CannedNet.git
synced 2026-10-25 15:09:23 -07:00
cleanup and routing fixes
This commit is contained in:
@@ -7,3 +7,4 @@ riderModule.iml
|
|||||||
/CannedNet.API/Migrations
|
/CannedNet.API/Migrations
|
||||||
CannedNet.sln.DotSettings.user
|
CannedNet.sln.DotSettings.user
|
||||||
CannedNet/Data/PrivateKey.pem
|
CannedNet/Data/PrivateKey.pem
|
||||||
|
/CannedNet/.zed
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
"AA=="
|
":3"
|
||||||
|
|||||||
@@ -1,38 +1,38 @@
|
|||||||
{
|
{
|
||||||
"Accounts": "https://cannednet.lapis.codes",
|
"Accounts": "https://cannednet.lapis.codes/accounts",
|
||||||
"AI": "https://cannednet.lapis.codes",
|
"AI": "https://cannednet.lapis.codes/ai",
|
||||||
"API": "https://cannednet.lapis.codes",
|
"API": "https://cannednet.lapis.codes/api",
|
||||||
"Auth": "https://cannednet.lapis.codes",
|
"Auth": "https://cannednet.lapis.codes/auth",
|
||||||
"BugReporting": "https://cannednet.lapis.codes",
|
"BugReporting": "https://cannednet.lapis.codes/bugreporting",
|
||||||
"Cards": "https://cannednet.lapis.codes",
|
"Cards": "https://cannednet.lapis.codes/cards",
|
||||||
"CDN": "https://cannednet.lapis.codes",
|
"CDN": "https://cannednet.lapis.codes/cdn",
|
||||||
"Chat": "https://cannednet.lapis.codes/chat",
|
"Chat": "https://cannednet.lapis.codes/chat",
|
||||||
"Clubs": "https://cannednet.lapis.codes",
|
"Clubs": "https://cannednet.lapis.codes/clubs",
|
||||||
"CMS": "https://cannednet.lapis.codes",
|
"CMS": "https://cannednet.lapis.codes/cms",
|
||||||
"Commerce": "https://cannednet.lapis.codes",
|
"Commerce": "https://cannednet.lapis.codes/commerce",
|
||||||
"Data": "https://cannednet.lapis.codes",
|
"Data": "https://cannednet.lapis.codes/data",
|
||||||
"DataCollection": "https://cannednet.lapis.codes",
|
"DataCollection": "https://cannednet.lapis.codes/datacollection",
|
||||||
"Discovery": "https://cannednet.lapis.codes",
|
"Discovery": "https://cannednet.lapis.codes/discovery",
|
||||||
"Econ": "https://cannednet.lapis.codes",
|
"Econ": "https://cannednet.lapis.codes/econ",
|
||||||
"GameLogs": "https://cannednet.lapis.codes",
|
"GameLogs": "https://cannednet.lapis.codes/gamelogs",
|
||||||
"Geo": "https://cannednet.lapis.codes",
|
"Geo": "https://cannednet.lapis.codes/geo",
|
||||||
"Images": "https://cannednet.lapis.codes/img",
|
"Images": "https://cannednet.lapis.codes/img",
|
||||||
"Leaderboard": "https://cannednet.lapis.codes",
|
"Leaderboard": "https://cannednet.lapis.codes/leaderboard",
|
||||||
"Link": "https://cannednet.lapis.codes",
|
"Link": "https://cannednet.lapis.codes/link",
|
||||||
"Lists": "https://cannednet.lapis.codes",
|
"Lists": "https://cannednet.lapis.codes/lists",
|
||||||
"Matchmaking": "https://cannednet.lapis.codes",
|
"Matchmaking": "https://cannednet.lapis.codes/match",
|
||||||
"Moderation": "https://cannednet.lapis.codes",
|
"Moderation": "https://cannednet.lapis.codes/moderation",
|
||||||
"Notifications": "https://cannednet.lapis.codes",
|
"Notifications": "https://cannednet.lapis.codes",
|
||||||
"PlatformNotifications": "https://cannednet.lapis.codes",
|
"PlatformNotifications": "https://cannednet.lapis.codes",
|
||||||
"PlayerSettings": "https://cannednet.lapis.codes/playersettings",
|
"PlayerSettings": "https://cannednet.lapis.codes/playersettings",
|
||||||
"RoomComments": "https://cannednet.lapis.codes",
|
"RoomComments": "https://cannednet.lapis.codes/roomcomments",
|
||||||
"RoomieIntegrations": "https://cannednet.lapis.codes",
|
"RoomieIntegrations": "https://cannednet.lapis.codes/roomieintegrations",
|
||||||
"Rooms": "https://cannednet.lapis.codes",
|
"Rooms": "https://cannednet.lapis.codes/rooms",
|
||||||
"Storage": "https://cannednet.lapis.codes",
|
"Storage": "https://cannednet.lapis.codes/storage",
|
||||||
"Strings": "https://cannednet.lapis.codes",
|
"Strings": "https://cannednet.lapis.codes/strings",
|
||||||
"StringsCDN": "https://cannednet.lapis.codes",
|
"StringsCDN": "https://cannednet.lapis.codes/stringscdn",
|
||||||
"Studio": "https://cannednet.lapis.codes",
|
"Studio": "https://cannednet.lapis.codes/studio",
|
||||||
"Thorn": "https://cannednet.lapis.codes",
|
"Thorn": "https://cannednet.lapis.codes/thorn",
|
||||||
"Videos": "https://cannednet.lapis.codes",
|
"Videos": "https://cannednet.lapis.codes/videos",
|
||||||
"WWW": "https://cannednet.lapis.codes"
|
"WWW": "https://cannednet.lapis.codes"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,12 +7,14 @@ using Microsoft.AspNetCore.Mvc;
|
|||||||
|
|
||||||
namespace CannedNet.Services.Controllers;
|
namespace CannedNet.Services.Controllers;
|
||||||
|
|
||||||
[ApiController, Route("api")]
|
[ApiController, Route("api/api")]
|
||||||
public class APIController : ControllerBase
|
public class APIController : ControllerBase
|
||||||
{
|
{
|
||||||
[HttpGet("config/v1/amplitude")]
|
[HttpGet("config/v1/amplitude")]
|
||||||
public async Task<IResult> Amplitude() {
|
public async Task<IResult> Amplitude()
|
||||||
return Results.Ok(new {
|
{
|
||||||
|
return Results.Ok(new
|
||||||
|
{
|
||||||
AmplitudeKey = "a",
|
AmplitudeKey = "a",
|
||||||
StatSigKey = "a",
|
StatSigKey = "a",
|
||||||
RudderStackKey = "a",
|
RudderStackKey = "a",
|
||||||
@@ -21,8 +23,10 @@ public class APIController : ControllerBase
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("config/v1/azurespeech")]
|
[HttpGet("config/v1/azurespeech")]
|
||||||
public async Task<IResult> AzureSpeech() {
|
public async Task<IResult> AzureSpeech()
|
||||||
return Results.Ok(new {
|
{
|
||||||
|
return Results.Ok(new
|
||||||
|
{
|
||||||
Key = "dce8de5b297747d9b5bddcc7f19e8c5b",
|
Key = "dce8de5b297747d9b5bddcc7f19e8c5b",
|
||||||
Region = "eastus",
|
Region = "eastus",
|
||||||
Enabled = false
|
Enabled = false
|
||||||
@@ -34,9 +38,10 @@ public class APIController : ControllerBase
|
|||||||
|
|
||||||
[HttpGet("gameconfigs/v1/all")]
|
[HttpGet("gameconfigs/v1/all")]
|
||||||
public async Task<IResult> GameConfigsV1All() => Results.Content(await System.IO.File.ReadAllTextAsync("JSON/gameconfigs.json"), "application/json");
|
public async Task<IResult> GameConfigsV1All() => Results.Content(await System.IO.File.ReadAllTextAsync("JSON/gameconfigs.json"), "application/json");
|
||||||
|
|
||||||
[HttpGet("versioncheck/v4")]
|
[HttpGet("versioncheck/v4")]
|
||||||
public async Task<IResult> VersionCheckV4() => Results.Ok(new {
|
public async Task<IResult> VersionCheckV4() => Results.Ok(new
|
||||||
|
{
|
||||||
VersionStatus = 0,
|
VersionStatus = 0,
|
||||||
UpdateNotificationStage = 0,
|
UpdateNotificationStage = 0,
|
||||||
IsVersionIslanded = false,
|
IsVersionIslanded = false,
|
||||||
@@ -48,15 +53,16 @@ public class APIController : ControllerBase
|
|||||||
|
|
||||||
[HttpGet("messages/v2/get")]
|
[HttpGet("messages/v2/get")]
|
||||||
public async Task<IResult> GetMessagesV2() => Results.Content("[]", "application/json");
|
public async Task<IResult> GetMessagesV2() => Results.Content("[]", "application/json");
|
||||||
|
|
||||||
[HttpGet("playerReputation/v1/{id}")]
|
[HttpGet("playerReputation/v1/{id}")]
|
||||||
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");
|
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");
|
||||||
|
|
||||||
[HttpGet("players/v1/progression/{id}")]
|
[HttpGet("players/v1/progression/{id}")]
|
||||||
public async Task<IResult> GetPlayersV1Progression(string id) => Results.Content($"{{\"PlayerId\":{id},\"Level\":1,\"XP\":0}}", "application/json");
|
public async Task<IResult> GetPlayersV1Progression(string id) => Results.Content($"{{\"PlayerId\":{id},\"Level\":1,\"XP\":0}}", "application/json");
|
||||||
|
|
||||||
[HttpPost("playerReputation/v2/bulk")]
|
[HttpPost("playerReputation/v2/bulk")]
|
||||||
public async Task<IResult> PostPlayerReputationV2Bulk(AppDbContext db) {
|
public async Task<IResult> PostPlayerReputationV2Bulk(AppDbContext db)
|
||||||
|
{
|
||||||
/*var ids = await ParseFormIds(httpRequest);
|
/*var ids = await ParseFormIds(httpRequest);
|
||||||
|
|
||||||
if (!ids.Any())
|
if (!ids.Any())
|
||||||
@@ -83,22 +89,24 @@ public class APIController : ControllerBase
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("players/v2/progression/bulk")]
|
[HttpPost("players/v2/progression/bulk")]
|
||||||
public async Task<IResult> PostProgressionBulkV2(AppDbContext db) {
|
public async Task<IResult> PostProgressionBulkV2(AppDbContext db)
|
||||||
|
{
|
||||||
List<int> ids = await ParseFormIds(HttpContext.Request);
|
List<int> ids = await ParseFormIds(HttpContext.Request);
|
||||||
|
|
||||||
if (!ids.Any())
|
if (!ids.Any())
|
||||||
return Results.Json(new List<PlayerProgressionBulkResponse>());
|
return Results.Json(new List<PlayerProgressionBulkResponse>());
|
||||||
|
|
||||||
List<PlayerProgressionBulkResponse> 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("v1/progression/bulk")]
|
[HttpPost("v1/progression/bulk")]
|
||||||
public async Task<IResult> PostProgressionBulkV1(AppDbContext db) {
|
public async Task<IResult> PostProgressionBulkV1(AppDbContext db)
|
||||||
|
{
|
||||||
List<int> ids = await ParseFormIds(HttpContext.Request);
|
List<int> ids = await ParseFormIds(HttpContext.Request);
|
||||||
|
|
||||||
if (!ids.Any())
|
if (!ids.Any())
|
||||||
@@ -121,28 +129,28 @@ public class APIController : ControllerBase
|
|||||||
int id = User.Identity.Name != null && int.TryParse(User.Identity.Name, out var parsedId) ? parsedId : -1;
|
int id = User.Identity.Name != null && int.TryParse(User.Identity.Name, out var parsedId) ? parsedId : -1;
|
||||||
HttpContext.Request.EnableBuffering();
|
HttpContext.Request.EnableBuffering();
|
||||||
var avatarUpdate = await System.Text.Json.JsonSerializer.DeserializeAsync<PlayerAvatar>(HttpContext.Request.Body);
|
var avatarUpdate = await System.Text.Json.JsonSerializer.DeserializeAsync<PlayerAvatar>(HttpContext.Request.Body);
|
||||||
|
|
||||||
if (avatarUpdate == null)
|
if (avatarUpdate == null)
|
||||||
return Results.BadRequest();
|
return Results.BadRequest();
|
||||||
|
|
||||||
var avatar = await db.PlayerAvatars
|
var avatar = await db.PlayerAvatars
|
||||||
.FirstOrDefaultAsync(a => a.OwnerAccountId == id);
|
.FirstOrDefaultAsync(a => a.OwnerAccountId == id);
|
||||||
|
|
||||||
if (avatar == null)
|
if (avatar == null)
|
||||||
{
|
{
|
||||||
avatar = new PlayerAvatar { OwnerAccountId = id };
|
avatar = new PlayerAvatar { OwnerAccountId = id };
|
||||||
db.PlayerAvatars.Add(avatar);
|
db.PlayerAvatars.Add(avatar);
|
||||||
}
|
}
|
||||||
|
|
||||||
avatar.OutfitSelections = avatarUpdate.OutfitSelections;
|
avatar.OutfitSelections = avatarUpdate.OutfitSelections;
|
||||||
avatar.FaceFeatures = avatarUpdate.FaceFeatures;
|
avatar.FaceFeatures = avatarUpdate.FaceFeatures;
|
||||||
avatar.SkinColor = avatarUpdate.SkinColor;
|
avatar.SkinColor = avatarUpdate.SkinColor;
|
||||||
avatar.HairColor = avatarUpdate.HairColor;
|
avatar.HairColor = avatarUpdate.HairColor;
|
||||||
|
|
||||||
await db.SaveChangesAsync();
|
await db.SaveChangesAsync();
|
||||||
return Results.Ok(avatar);
|
return Results.Ok(avatar);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("PlayerReporting/v1/moderationBlockDetails")]
|
[HttpGet("PlayerReporting/v1/moderationBlockDetails")]
|
||||||
public IResult GetModerationBlockDetails()
|
public IResult GetModerationBlockDetails()
|
||||||
{
|
{
|
||||||
@@ -160,13 +168,16 @@ public class APIController : ControllerBase
|
|||||||
[Authorize]
|
[Authorize]
|
||||||
public async Task<IResult> GetSettings(AppDbContext db, JwtTokenService jwtService)
|
public async Task<IResult> GetSettings(AppDbContext db, JwtTokenService jwtService)
|
||||||
{
|
{
|
||||||
|
if (User == null || User.Identity == null)
|
||||||
|
return Results.NotFound();
|
||||||
|
|
||||||
int id = User.Identity.Name != null && int.TryParse(User.Identity.Name, out var parsedId) ? parsedId : -1;
|
int id = User.Identity.Name != null && int.TryParse(User.Identity.Name, out var parsedId) ? parsedId : -1;
|
||||||
|
|
||||||
var settings = await db.PlayerSettings
|
var settings = await db.PlayerSettings
|
||||||
.Where(s => s.PlayerId == id)
|
.Where(s => s.PlayerId == id)
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
if (!settings.Any())
|
if (settings.Count == 0)
|
||||||
{
|
{
|
||||||
var defaults = new List<PlayerSetting>
|
var defaults = new List<PlayerSetting>
|
||||||
{
|
{
|
||||||
@@ -206,10 +217,10 @@ public class APIController : ControllerBase
|
|||||||
await db.SaveChangesAsync();
|
await db.SaveChangesAsync();
|
||||||
settings = defaults;
|
settings = defaults;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Results.Json(settings);
|
return Results.Json(settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("accounts/v1/getBio")]
|
[HttpGet("accounts/v1/getBio")]
|
||||||
[Authorize]
|
[Authorize]
|
||||||
public async Task<IResult> GetAccountBio(AppDbContext db)
|
public async Task<IResult> GetAccountBio(AppDbContext db)
|
||||||
@@ -219,46 +230,53 @@ public class APIController : ControllerBase
|
|||||||
var bio = await db.PlayerBios
|
var bio = await db.PlayerBios
|
||||||
.Where(s => accountId == accountId)
|
.Where(s => accountId == accountId)
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
return Results.Json(bio);
|
return Results.Json(bio);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
[HttpGet("communityboard/v2/current")]
|
[HttpGet("communityboard/v2/current")]
|
||||||
public async Task<IResult> CommunityBoardCurrent() {
|
public async Task<IResult> CommunityBoardCurrent()
|
||||||
|
{
|
||||||
var json = System.IO.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");
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("playerevents/v1/all")]
|
[HttpGet("playerevents/v1/all")]
|
||||||
public async Task<IResult> PlayerEventsAll() {
|
public async Task<IResult> PlayerEventsAll()
|
||||||
|
{
|
||||||
return Results.Content("{\"Created\":[],\"Responses\":[]}", "application/json");
|
return Results.Content("{\"Created\":[],\"Responses\":[]}", "application/json");
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("storefronts/v1/p2p/betaEnabled")]
|
[HttpGet("storefronts/v1/p2p/betaEnabled")]
|
||||||
public IResult StorefrontsP2PBetaEnabled() {
|
public IResult StorefrontsP2PBetaEnabled()
|
||||||
|
{
|
||||||
return Results.Content("false", "application/json");
|
return Results.Content("false", "application/json");
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("announcement/v1/get")]
|
[HttpGet("announcement/v1/get")]
|
||||||
public async Task<IResult> AnnouncementGet() {
|
public async Task<IResult> AnnouncementGet()
|
||||||
|
{
|
||||||
var json = System.IO.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");
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("quickPlay/v1/getandclear")]
|
[HttpGet("quickPlay/v1/getandclear")]
|
||||||
public async Task<IResult> QuickPlayGetAndClear() {
|
public async Task<IResult> QuickPlayGetAndClear()
|
||||||
|
{
|
||||||
return Results.Content("{\"RoomName\":null,\"ActionCode\":null,\"TargetPlayerId\":null}", "application/json");
|
return Results.Content("{\"RoomName\":null,\"ActionCode\":null,\"TargetPlayerId\":null}", "application/json");
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("roomkeys/v1/room")]
|
[HttpGet("roomkeys/v1/room")]
|
||||||
public async Task<IResult> RoomKeysRoom() {
|
public async Task<IResult> RoomKeysRoom()
|
||||||
|
{
|
||||||
var roomid = Request.Query["roomId"];
|
var roomid = Request.Query["roomId"];
|
||||||
return Results.Content("[]", "application/json");
|
return Results.Content("[]", "application/json");
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("/roomserver/rooms/bulk")]
|
[HttpGet("/roomserver/rooms/bulk")]
|
||||||
public async Task<IResult> RoomserverRoomsBulk(AppDbContext db) {
|
public async Task<IResult> RoomserverRoomsBulk(AppDbContext db)
|
||||||
|
{
|
||||||
var idParam = Request.Query["id"].FirstOrDefault();
|
var idParam = Request.Query["id"].FirstOrDefault();
|
||||||
var nameParam = Request.Query["name"].FirstOrDefault();
|
var nameParam = Request.Query["name"].FirstOrDefault();
|
||||||
|
|
||||||
@@ -360,7 +378,8 @@ public class APIController : ControllerBase
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("/roomserver/rooms/hot")]
|
[HttpGet("/roomserver/rooms/hot")]
|
||||||
public async Task<IResult> RoomserverRoomsHot(AppDbContext db) {
|
public async Task<IResult> RoomserverRoomsHot(AppDbContext db)
|
||||||
|
{
|
||||||
var tagFilter = Request.Query["tag"].FirstOrDefault()?.ToLower();
|
var tagFilter = Request.Query["tag"].FirstOrDefault()?.ToLower();
|
||||||
var allRooms = await db.Rooms.ToListAsync();
|
var allRooms = await db.Rooms.ToListAsync();
|
||||||
|
|
||||||
@@ -427,7 +446,8 @@ public class APIController : ControllerBase
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("/roomserver/roomsandplaylists/hot")]
|
[HttpGet("/roomserver/roomsandplaylists/hot")]
|
||||||
public async Task<IResult> RoomserverRoomsAndPlaylistsHot(AppDbContext db) {
|
public async Task<IResult> RoomserverRoomsAndPlaylistsHot(AppDbContext db)
|
||||||
|
{
|
||||||
var allRooms = await db.Rooms.Where(r => !r.IsDorm).OrderByDescending(r => r.Id).ToListAsync();
|
var allRooms = await db.Rooms.Where(r => !r.IsDorm).OrderByDescending(r => r.Id).ToListAsync();
|
||||||
var results = new List<object>();
|
var results = new List<object>();
|
||||||
|
|
||||||
@@ -481,7 +501,8 @@ public class APIController : ControllerBase
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("/roomserver/rooms/{id}")]
|
[HttpGet("/roomserver/rooms/{id}")]
|
||||||
public async Task<IResult> RoomserverRoomsId(string id, AppDbContext db) {
|
public async Task<IResult> RoomserverRoomsId(string id, AppDbContext db)
|
||||||
|
{
|
||||||
if (!int.TryParse(id, out var roomId))
|
if (!int.TryParse(id, out var roomId))
|
||||||
return Results.NotFound();
|
return Results.NotFound();
|
||||||
|
|
||||||
@@ -534,23 +555,27 @@ public class APIController : ControllerBase
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("images/v2/named")]
|
[HttpGet("images/v2/named")]
|
||||||
public async Task<IResult> NamedImages() {
|
public async Task<IResult> NamedImages()
|
||||||
|
{
|
||||||
var json = System.IO.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");
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("objectives/v1/updateobjective")]
|
[HttpPost("objectives/v1/updateobjective")]
|
||||||
public async Task<IResult> UpdateObjective() {
|
public async Task<IResult> UpdateObjective()
|
||||||
|
{
|
||||||
return Results.Ok();
|
return Results.Ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("PlayerReporting/v1/hile")]
|
[HttpPost("PlayerReporting/v1/hile")]
|
||||||
public async Task<IResult> PlayerReportingHile() {
|
public async Task<IResult> PlayerReportingHile()
|
||||||
|
{
|
||||||
return Results.Ok();
|
return Results.Ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("storefronts/v3/giftdropstore/300")]
|
[HttpGet("storefronts/v3/giftdropstore/300")]
|
||||||
public async Task<IResult> GiftDropStore300(StorefrontFillService storefrontService) {
|
public async Task<IResult> GiftDropStore300(StorefrontFillService storefrontService)
|
||||||
|
{
|
||||||
var storefronts = await storefrontService.GetStorefrontsAsync();
|
var storefronts = await storefrontService.GetStorefrontsAsync();
|
||||||
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)
|
||||||
@@ -568,11 +593,26 @@ public class APIController : ControllerBase
|
|||||||
item.NewUntil,
|
item.NewUntil,
|
||||||
GiftDrops = item.GiftDrops.Select(gd => new
|
GiftDrops = item.GiftDrops.Select(gd => new
|
||||||
{
|
{
|
||||||
gd.Id, gd.StorefrontItemId, gd.GiftDropId, gd.FriendlyName, gd.Tooltip,
|
gd.Id,
|
||||||
gd.ConsumableItemDesc, gd.AvatarItemDesc, gd.AvatarItemType,
|
gd.StorefrontItemId,
|
||||||
gd.EquipmentPrefabName, gd.EquipmentModificationGuid, gd.IsQuery,
|
gd.GiftDropId,
|
||||||
gd.Unique, gd.SubscribersOnly, gd.Level, gd.Rarity, gd.CurrencyType,
|
gd.FriendlyName,
|
||||||
gd.Currency, gd.Context, gd.ItemSetId, gd.ItemSetFriendlyName
|
gd.Tooltip,
|
||||||
|
gd.ConsumableItemDesc,
|
||||||
|
gd.AvatarItemDesc,
|
||||||
|
gd.AvatarItemType,
|
||||||
|
gd.EquipmentPrefabName,
|
||||||
|
gd.EquipmentModificationGuid,
|
||||||
|
gd.IsQuery,
|
||||||
|
gd.Unique,
|
||||||
|
gd.SubscribersOnly,
|
||||||
|
gd.Level,
|
||||||
|
gd.Rarity,
|
||||||
|
gd.CurrencyType,
|
||||||
|
gd.Currency,
|
||||||
|
gd.Context,
|
||||||
|
gd.ItemSetId,
|
||||||
|
gd.ItemSetFriendlyName
|
||||||
}).ToList(),
|
}).ToList(),
|
||||||
Prices = item.Prices.Select(p => new { p.Id, p.StorefrontItemId, p.CurrencyType, p.Price }).ToList()
|
Prices = item.Prices.Select(p => new { p.Id, p.StorefrontItemId, p.CurrencyType, p.Price }).ToList()
|
||||||
}).ToList();
|
}).ToList();
|
||||||
@@ -580,7 +620,8 @@ public class APIController : ControllerBase
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("storefronts/v3/giftdropstore/2")]
|
[HttpGet("storefronts/v3/giftdropstore/2")]
|
||||||
public async Task<IResult> GiftDropStore2(StorefrontFillService storefrontService) {
|
public async Task<IResult> GiftDropStore2(StorefrontFillService storefrontService)
|
||||||
|
{
|
||||||
var storefronts = await storefrontService.GetStorefrontsAsync();
|
var storefronts = await storefrontService.GetStorefrontsAsync();
|
||||||
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)
|
||||||
@@ -598,11 +639,26 @@ public class APIController : ControllerBase
|
|||||||
item.NewUntil,
|
item.NewUntil,
|
||||||
GiftDrops = item.GiftDrops.Select(gd => new
|
GiftDrops = item.GiftDrops.Select(gd => new
|
||||||
{
|
{
|
||||||
gd.Id, gd.StorefrontItemId, gd.GiftDropId, gd.FriendlyName, gd.Tooltip,
|
gd.Id,
|
||||||
gd.ConsumableItemDesc, gd.AvatarItemDesc, gd.AvatarItemType,
|
gd.StorefrontItemId,
|
||||||
gd.EquipmentPrefabName, gd.EquipmentModificationGuid, gd.IsQuery,
|
gd.GiftDropId,
|
||||||
gd.Unique, gd.SubscribersOnly, gd.Level, gd.Rarity, gd.CurrencyType,
|
gd.FriendlyName,
|
||||||
gd.Currency, gd.Context, gd.ItemSetId, gd.ItemSetFriendlyName
|
gd.Tooltip,
|
||||||
|
gd.ConsumableItemDesc,
|
||||||
|
gd.AvatarItemDesc,
|
||||||
|
gd.AvatarItemType,
|
||||||
|
gd.EquipmentPrefabName,
|
||||||
|
gd.EquipmentModificationGuid,
|
||||||
|
gd.IsQuery,
|
||||||
|
gd.Unique,
|
||||||
|
gd.SubscribersOnly,
|
||||||
|
gd.Level,
|
||||||
|
gd.Rarity,
|
||||||
|
gd.CurrencyType,
|
||||||
|
gd.Currency,
|
||||||
|
gd.Context,
|
||||||
|
gd.ItemSetId,
|
||||||
|
gd.ItemSetFriendlyName
|
||||||
}).ToList(),
|
}).ToList(),
|
||||||
Prices = item.Prices.Select(p => new { p.Id, p.StorefrontItemId, p.CurrencyType, p.Price }).ToList()
|
Prices = item.Prices.Select(p => new { p.Id, p.StorefrontItemId, p.CurrencyType, p.Price }).ToList()
|
||||||
}).ToList();
|
}).ToList();
|
||||||
@@ -611,7 +667,8 @@ public class APIController : ControllerBase
|
|||||||
|
|
||||||
[HttpPost("storefronts/v2/buyItem")]
|
[HttpPost("storefronts/v2/buyItem")]
|
||||||
[Authorize]
|
[Authorize]
|
||||||
public async Task<IResult> BuyItem(BuyItemRequest buyRequest, AppDbContext db, NotificationService notificationService) {
|
public async Task<IResult> BuyItem(BuyItemRequest buyRequest, AppDbContext db, NotificationService notificationService)
|
||||||
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
int id = User.Identity.Name != null && int.TryParse(User.Identity.Name, out var parsedId) ? parsedId : -1;
|
int id = User.Identity.Name != null && int.TryParse(User.Identity.Name, out var parsedId) ? parsedId : -1;
|
||||||
@@ -679,21 +736,34 @@ public class APIController : ControllerBase
|
|||||||
|
|
||||||
var giftData = storedGifts.Select(rg => new GiftData
|
var giftData = storedGifts.Select(rg => new GiftData
|
||||||
{
|
{
|
||||||
Id = rg.Id, FromPlayerId = null,
|
Id = rg.Id,
|
||||||
ConsumableItemDesc = rg.ConsumableItemDesc, AvatarItemDesc = rg.AvatarItemDesc,
|
FromPlayerId = null,
|
||||||
FriendlyName = rg.FriendlyName, AvatarItemType = rg.AvatarItemType,
|
ConsumableItemDesc = rg.ConsumableItemDesc,
|
||||||
EquipmentPrefabName = rg.EquipmentPrefabName, EquipmentModificationGuid = rg.EquipmentModificationGuid,
|
AvatarItemDesc = rg.AvatarItemDesc,
|
||||||
CurrencyType = rg.CurrencyType, Currency = rg.Currency, Xp = rg.Xp, Level = rg.Level,
|
FriendlyName = rg.FriendlyName,
|
||||||
Platform = rg.Platform, PlatformsToSpawnOn = rg.PlatformsToSpawnOn, BalanceType = rg.BalanceType,
|
AvatarItemType = rg.AvatarItemType,
|
||||||
GiftContext = rg.GiftContext, GiftRarity = rg.GiftRarity, Message = rg.Message
|
EquipmentPrefabName = rg.EquipmentPrefabName,
|
||||||
|
EquipmentModificationGuid = rg.EquipmentModificationGuid,
|
||||||
|
CurrencyType = rg.CurrencyType,
|
||||||
|
Currency = rg.Currency,
|
||||||
|
Xp = rg.Xp,
|
||||||
|
Level = rg.Level,
|
||||||
|
Platform = rg.Platform,
|
||||||
|
PlatformsToSpawnOn = rg.PlatformsToSpawnOn,
|
||||||
|
BalanceType = rg.BalanceType,
|
||||||
|
GiftContext = rg.GiftContext,
|
||||||
|
GiftRarity = rg.GiftRarity,
|
||||||
|
Message = rg.Message
|
||||||
}).ToList();
|
}).ToList();
|
||||||
|
|
||||||
var balanceUpdate = new BalanceUpdate { UpdateResponse = 0, Data = giftData };
|
var balanceUpdate = new BalanceUpdate { UpdateResponse = 0, Data = giftData };
|
||||||
var response = new BuyItemResponse
|
var response = new BuyItemResponse
|
||||||
{
|
{
|
||||||
BalanceUpdates = new List<BalanceUpdate> { balanceUpdate },
|
BalanceUpdates = new List<BalanceUpdate> { balanceUpdate },
|
||||||
Balance = tokenBalance.Balance, CurrencyType = buyRequest.CurrencyType,
|
Balance = tokenBalance.Balance,
|
||||||
BalanceType = -1, Platform = -1
|
CurrencyType = buyRequest.CurrencyType,
|
||||||
|
BalanceType = -1,
|
||||||
|
Platform = -1
|
||||||
};
|
};
|
||||||
|
|
||||||
try
|
try
|
||||||
@@ -722,7 +792,8 @@ public class APIController : ControllerBase
|
|||||||
|
|
||||||
[HttpPost("avatar/v2/gifts/generate")]
|
[HttpPost("avatar/v2/gifts/generate")]
|
||||||
[Authorize]
|
[Authorize]
|
||||||
public async Task<IResult> AvatarGiftsGenerate(AppDbContext db) {
|
public async Task<IResult> AvatarGiftsGenerate(AppDbContext db)
|
||||||
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
int id = User.Identity.Name != null && int.TryParse(User.Identity.Name, out var parsedId) ? parsedId : -1;
|
int id = User.Identity.Name != null && int.TryParse(User.Identity.Name, out var parsedId) ? parsedId : -1;
|
||||||
@@ -808,14 +879,26 @@ public class APIController : ControllerBase
|
|||||||
|
|
||||||
var receivedGift = new ReceivedGift
|
var receivedGift = new ReceivedGift
|
||||||
{
|
{
|
||||||
ReceiverAccountId = id, FromPlayerId = 1, Message = message,
|
ReceiverAccountId = id,
|
||||||
ConsumableItemDesc = consumableItemDesc, AvatarItemDesc = avatarItemDesc,
|
FromPlayerId = 1,
|
||||||
FriendlyName = friendlyName, AvatarItemType = avatarItemType,
|
Message = message,
|
||||||
EquipmentPrefabName = "", EquipmentModificationGuid = "",
|
ConsumableItemDesc = consumableItemDesc,
|
||||||
CurrencyType = currencyType, Currency = currency, Xp = xp, Level = 0,
|
AvatarItemDesc = avatarItemDesc,
|
||||||
Platform = -1, PlatformsToSpawnOn = -1, BalanceType = 0,
|
FriendlyName = friendlyName,
|
||||||
GiftContext = giftContext, GiftRarity = giftRarity,
|
AvatarItemType = avatarItemType,
|
||||||
ReceivedAt = DateTime.UtcNow, IsConsumed = false
|
EquipmentPrefabName = "",
|
||||||
|
EquipmentModificationGuid = "",
|
||||||
|
CurrencyType = currencyType,
|
||||||
|
Currency = currency,
|
||||||
|
Xp = xp,
|
||||||
|
Level = 0,
|
||||||
|
Platform = -1,
|
||||||
|
PlatformsToSpawnOn = -1,
|
||||||
|
BalanceType = 0,
|
||||||
|
GiftContext = giftContext,
|
||||||
|
GiftRarity = giftRarity,
|
||||||
|
ReceivedAt = DateTime.UtcNow,
|
||||||
|
IsConsumed = false
|
||||||
};
|
};
|
||||||
|
|
||||||
db.ReceivedGifts.Add(receivedGift);
|
db.ReceivedGifts.Add(receivedGift);
|
||||||
@@ -823,13 +906,24 @@ public class APIController : ControllerBase
|
|||||||
|
|
||||||
return Results.Ok(new
|
return Results.Ok(new
|
||||||
{
|
{
|
||||||
Id = receivedGift.Id, FromPlayerId = 1,
|
Id = receivedGift.Id,
|
||||||
ConsumableItemDesc = consumableItemDesc, AvatarItemDesc = avatarItemDesc,
|
FromPlayerId = 1,
|
||||||
FriendlyName = friendlyName, AvatarItemType = avatarItemType,
|
ConsumableItemDesc = consumableItemDesc,
|
||||||
EquipmentPrefabName = "", EquipmentModificationGuid = "",
|
AvatarItemDesc = avatarItemDesc,
|
||||||
CurrencyType = currencyType, Currency = currency, Xp = xp, Level = 0,
|
FriendlyName = friendlyName,
|
||||||
Platform = -1, PlatformsToSpawnOn = -1, BalanceType = 0,
|
AvatarItemType = avatarItemType,
|
||||||
GiftContext = giftContext, GiftRarity = giftRarity, Message = message
|
EquipmentPrefabName = "",
|
||||||
|
EquipmentModificationGuid = "",
|
||||||
|
CurrencyType = currencyType,
|
||||||
|
Currency = currency,
|
||||||
|
Xp = xp,
|
||||||
|
Level = 0,
|
||||||
|
Platform = -1,
|
||||||
|
PlatformsToSpawnOn = -1,
|
||||||
|
BalanceType = 0,
|
||||||
|
GiftContext = giftContext,
|
||||||
|
GiftRarity = giftRarity,
|
||||||
|
Message = message
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@@ -840,7 +934,8 @@ public class APIController : ControllerBase
|
|||||||
|
|
||||||
[HttpPost("avatar/v2/gifts/consume/")]
|
[HttpPost("avatar/v2/gifts/consume/")]
|
||||||
[Authorize]
|
[Authorize]
|
||||||
public async Task<IResult> AvatarGiftsConsume(AppDbContext db) {
|
public async Task<IResult> AvatarGiftsConsume(AppDbContext db)
|
||||||
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
int id = User.Identity.Name != null && int.TryParse(User.Identity.Name, out var parsedId) ? parsedId : -1;
|
int id = User.Identity.Name != null && int.TryParse(User.Identity.Name, out var parsedId) ? parsedId : -1;
|
||||||
@@ -889,8 +984,11 @@ public class APIController : ControllerBase
|
|||||||
Ids = new List<int> { giftId },
|
Ids = new List<int> { giftId },
|
||||||
CreatedAts = new List<DateTime> { DateTime.UtcNow },
|
CreatedAts = new List<DateTime> { DateTime.UtcNow },
|
||||||
ConsumableItemDesc = receivedGift.ConsumableItemDesc,
|
ConsumableItemDesc = receivedGift.ConsumableItemDesc,
|
||||||
Count = 1, InitialCount = 1, IsActive = false,
|
Count = 1,
|
||||||
ActiveDurationMinutes = 0, IsTransferable = false
|
InitialCount = 1,
|
||||||
|
IsActive = false,
|
||||||
|
ActiveDurationMinutes = 0,
|
||||||
|
IsTransferable = false
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -921,8 +1019,10 @@ public class APIController : ControllerBase
|
|||||||
{
|
{
|
||||||
db.TokenBalances.Add(new TokenBalance
|
db.TokenBalances.Add(new TokenBalance
|
||||||
{
|
{
|
||||||
Id = id, CurrencyType = receivedGift.CurrencyType,
|
Id = id,
|
||||||
BalanceType = -1, Balance = receivedGift.Currency
|
CurrencyType = receivedGift.CurrencyType,
|
||||||
|
BalanceType = -1,
|
||||||
|
Balance = receivedGift.Currency
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -946,18 +1046,21 @@ public class APIController : ControllerBase
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("rooms/v1/filters")]
|
[HttpGet("rooms/v1/filters")]
|
||||||
public async Task<IResult> RoomsFilters() {
|
public async Task<IResult> RoomsFilters()
|
||||||
|
{
|
||||||
var json = System.IO.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");
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("/roomserver/rooms/{id}/interactionby/me")]
|
[HttpGet("/roomserver/rooms/{id}/interactionby/me")]
|
||||||
public async Task<IResult> RoomInteractionByMe(string id) {
|
public async Task<IResult> RoomInteractionByMe(string id)
|
||||||
|
{
|
||||||
return Results.Content("{\"Cheered\":false,\"Favorited\":false}", "application/json");
|
return Results.Content("{\"Cheered\":false,\"Favorited\":false}", "application/json");
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("images/v4/uploadsaved")]
|
[HttpPost("images/v4/uploadsaved")]
|
||||||
public async Task<IResult> ImageUploadSaved() {
|
public async Task<IResult> ImageUploadSaved()
|
||||||
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var form = await HttpContext.Request.ReadFormAsync();
|
var form = await HttpContext.Request.ReadFormAsync();
|
||||||
@@ -986,7 +1089,8 @@ public class APIController : ControllerBase
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("config/v1/backtrace")]
|
[HttpGet("config/v1/backtrace")]
|
||||||
public IResult BacktraceConfig() {
|
public IResult BacktraceConfig()
|
||||||
|
{
|
||||||
return Results.Ok(new
|
return Results.Ok(new
|
||||||
{
|
{
|
||||||
ReportBudget = 125,
|
ReportBudget = 125,
|
||||||
@@ -1001,6 +1105,205 @@ public class APIController : ControllerBase
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpPost("settings/v2/set")]
|
||||||
|
[Authorize]
|
||||||
|
public async Task<IResult> SetSettings(AppDbContext db)
|
||||||
|
{
|
||||||
|
if (!int.TryParse(User.Identity?.Name, out var id))
|
||||||
|
return Results.Unauthorized();
|
||||||
|
|
||||||
|
HttpContext.Request.EnableBuffering();
|
||||||
|
HttpContext.Request.Body.Position = 0;
|
||||||
|
using var reader = new StreamReader(HttpContext.Request.Body);
|
||||||
|
var body = await reader.ReadToEndAsync();
|
||||||
|
|
||||||
|
Console.WriteLine($"Settings request body: {body}");
|
||||||
|
|
||||||
|
var settings = new List<PlayerSetting>();
|
||||||
|
|
||||||
|
if (body.TrimStart().StartsWith("["))
|
||||||
|
{
|
||||||
|
settings = System.Text.Json.JsonSerializer.Deserialize<List<PlayerSetting>>(body) ?? [];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var single = System.Text.Json.JsonSerializer.Deserialize<PlayerSetting>(body);
|
||||||
|
if (single != null) settings.Add(single);
|
||||||
|
}
|
||||||
|
|
||||||
|
settings = settings.Where(s => !string.IsNullOrEmpty(s.Key)).ToList();
|
||||||
|
|
||||||
|
if (settings.Count == 0)
|
||||||
|
return Results.Ok();
|
||||||
|
|
||||||
|
db.PlayerSettings.RemoveRange(db.PlayerSettings.Where(s => s.PlayerId == id));
|
||||||
|
|
||||||
|
foreach (var setting in settings)
|
||||||
|
{
|
||||||
|
setting.PlayerId = id;
|
||||||
|
setting.Key = setting.Key ?? "";
|
||||||
|
setting.Value = setting.Value ?? "";
|
||||||
|
db.PlayerSettings.Add(setting);
|
||||||
|
}
|
||||||
|
|
||||||
|
await db.SaveChangesAsync();
|
||||||
|
return Results.Ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[HttpGet("equipment/v2/getUnlocked")]
|
||||||
|
public async Task<IResult> GetEquipmentUnlocked()
|
||||||
|
{
|
||||||
|
return Results.Content("[]", "application/json");
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("consumables/v2/getUnlocked")]
|
||||||
|
[Authorize]
|
||||||
|
public async Task<IResult> GetConsumablesUnlocked(AppDbContext db)
|
||||||
|
{
|
||||||
|
if (!int.TryParse(User.Identity?.Name, out var id))
|
||||||
|
return Results.Unauthorized();
|
||||||
|
|
||||||
|
var consumables = await db.ConsumableItems
|
||||||
|
.Where(c => c.OwnerAccountId == id)
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
|
return Results.Json(consumables);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("storefronts/v4/balance/2")]
|
||||||
|
[Authorize]
|
||||||
|
public async Task<IResult> GetStorefrontBalance(AppDbContext db)
|
||||||
|
{
|
||||||
|
if (!int.TryParse(User.Identity?.Name, out var id))
|
||||||
|
return Results.Unauthorized();
|
||||||
|
|
||||||
|
var balance = await db.TokenBalances
|
||||||
|
.Where(s => s.Id == id)
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
|
return Results.Json(balance);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("storefronts/v3/giftdropstore/3")]
|
||||||
|
public async Task<IResult> GetGiftDropStore3(AppDbContext db, StorefrontFillService storefrontService)
|
||||||
|
{
|
||||||
|
var storefronts = await storefrontService.GetStorefrontsAsync();
|
||||||
|
var storefront = storefronts.FirstOrDefault(s => s.StorefrontType == 2 && s.Name == "watch_store");
|
||||||
|
if (storefront == null)
|
||||||
|
{
|
||||||
|
var json = System.IO.File.ReadAllText("JSON/storefront3.json");
|
||||||
|
return Results.Content(json, "application/json");
|
||||||
|
}
|
||||||
|
var storeItems = storefront.Items.Select(item => new
|
||||||
|
{
|
||||||
|
item.Id,
|
||||||
|
item.StorefrontId,
|
||||||
|
item.PurchasableItemId,
|
||||||
|
item.Type,
|
||||||
|
item.IsFeatured,
|
||||||
|
item.NewUntil,
|
||||||
|
GiftDrops = item.GiftDrops.Select(gd => new
|
||||||
|
{
|
||||||
|
gd.Id,
|
||||||
|
gd.StorefrontItemId,
|
||||||
|
gd.GiftDropId,
|
||||||
|
gd.FriendlyName,
|
||||||
|
gd.Tooltip,
|
||||||
|
gd.ConsumableItemDesc,
|
||||||
|
gd.AvatarItemDesc,
|
||||||
|
gd.AvatarItemType,
|
||||||
|
gd.EquipmentPrefabName,
|
||||||
|
gd.EquipmentModificationGuid,
|
||||||
|
gd.IsQuery,
|
||||||
|
gd.Unique,
|
||||||
|
gd.SubscribersOnly,
|
||||||
|
gd.Level,
|
||||||
|
gd.Rarity,
|
||||||
|
gd.CurrencyType,
|
||||||
|
gd.Currency,
|
||||||
|
gd.Context,
|
||||||
|
gd.ItemSetId,
|
||||||
|
gd.ItemSetFriendlyName
|
||||||
|
}).ToList(),
|
||||||
|
Prices = item.Prices.Select(p => new
|
||||||
|
{
|
||||||
|
p.Id,
|
||||||
|
p.StorefrontItemId,
|
||||||
|
p.CurrencyType,
|
||||||
|
p.Price
|
||||||
|
}).ToList()
|
||||||
|
}).ToList();
|
||||||
|
var response = new { storefront.Id, storefront.Name, storefront.StorefrontType, storefront.NextUpdate, StoreItems = storeItems };
|
||||||
|
return Results.Ok(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("challenge/v2/getCurrent")]
|
||||||
|
public async Task<IResult> GetCurrentChallenge()
|
||||||
|
{
|
||||||
|
var json = System.IO.File.ReadAllText("JSON/weeklychallenge.json");
|
||||||
|
return Results.Content(json, "application/json");
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("avatar/v3/saved")]
|
||||||
|
[Authorize]
|
||||||
|
public async Task<IResult> GetSavedAvatars(AppDbContext db)
|
||||||
|
{
|
||||||
|
if (!int.TryParse(User.Identity?.Name, out var id))
|
||||||
|
return Results.Unauthorized();
|
||||||
|
|
||||||
|
var items = await db.SavedOutfits
|
||||||
|
.Where(i => i.OwnerAccountId == id)
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
|
return Results.Json(items);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("avatar/v2/gifts")]
|
||||||
|
[Authorize]
|
||||||
|
public async Task<IResult> GetGifts(AppDbContext db)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!int.TryParse(User.Identity?.Name, out var id))
|
||||||
|
return Results.Unauthorized();
|
||||||
|
|
||||||
|
var pendingGifts = await db.ReceivedGifts
|
||||||
|
.Where(rg => rg.ReceiverAccountId == id && !rg.IsConsumed)
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
|
return Results.Json(pendingGifts);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return Results.Problem($"Error retrieving gifts: {ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("gamerewards/v1/pending")]
|
||||||
|
public async Task<IResult> GetGameRewardsPending()
|
||||||
|
{
|
||||||
|
return Results.Content("[]", "application/json");
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("roomkeys/v1/mine")]
|
||||||
|
public async Task<IResult> GetRoomKeysMine()
|
||||||
|
{
|
||||||
|
return Results.Content("[]", "application/json");
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost("CampusCard/v1/UpdateAndGetSubscription")]
|
||||||
|
public async Task<IResult> UpdateAndGetSubscription()
|
||||||
|
{
|
||||||
|
return Results.Json(new { subscription = (object?)null, platformAccountSubscribedPlayerId = (object?)null });
|
||||||
|
}
|
||||||
|
|
||||||
|
[Authorize]
|
||||||
|
[HttpGet("customAvatarItems/v1/isCreationAllowedForAccount")]
|
||||||
|
public async Task<IResult> IsCustomAvatarItemsCreationAllowedForAccount()
|
||||||
|
{
|
||||||
|
return Results.Json(new { isAllowed = true });
|
||||||
|
}
|
||||||
|
|
||||||
private static object[]? TryDeserializeTags(string json)
|
private static object[]? TryDeserializeTags(string json)
|
||||||
{
|
{
|
||||||
@@ -1009,7 +1312,7 @@ public class APIController : ControllerBase
|
|||||||
var tags = System.Text.Json.JsonSerializer.Deserialize<RoomTag[]>(json);
|
var tags = System.Text.Json.JsonSerializer.Deserialize<RoomTag[]>(json);
|
||||||
if (tags != null)
|
if (tags != null)
|
||||||
return tags.Cast<object>().ToArray();
|
return tags.Cast<object>().ToArray();
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
@@ -1033,13 +1336,13 @@ public class APIController : ControllerBase
|
|||||||
private static async Task<List<int>> ParseFormIds(HttpRequest httpRequest)
|
private static async Task<List<int>> ParseFormIds(HttpRequest httpRequest)
|
||||||
{
|
{
|
||||||
var ids = new List<int>();
|
var ids = new List<int>();
|
||||||
|
|
||||||
if (httpRequest.ContentLength.HasValue && httpRequest.ContentLength > 0)
|
if (httpRequest.ContentLength.HasValue && httpRequest.ContentLength > 0)
|
||||||
{
|
{
|
||||||
httpRequest.EnableBuffering();
|
httpRequest.EnableBuffering();
|
||||||
using var reader = new StreamReader(httpRequest.Body, leaveOpen: true);
|
using var reader = new StreamReader(httpRequest.Body, leaveOpen: true);
|
||||||
var body = await reader.ReadToEndAsync();
|
var body = await reader.ReadToEndAsync();
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(body))
|
if (!string.IsNullOrWhiteSpace(body))
|
||||||
{
|
{
|
||||||
foreach (var pair in body.Split('&'))
|
foreach (var pair in body.Split('&'))
|
||||||
@@ -1057,11 +1360,11 @@ public class APIController : ControllerBase
|
|||||||
}
|
}
|
||||||
httpRequest.Body.Position = 0;
|
httpRequest.Body.Position = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ids;
|
return ids;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private static readonly string ImagesDir;
|
private static readonly string ImagesDir;
|
||||||
static APIController()
|
static APIController()
|
||||||
|
|||||||
@@ -6,10 +6,10 @@ using Microsoft.Extensions.Primitives;
|
|||||||
|
|
||||||
namespace CannedNet.Services.Controllers;
|
namespace CannedNet.Services.Controllers;
|
||||||
|
|
||||||
[ApiController, Route("account")]
|
[ApiController, Route("accounts")]
|
||||||
public class AccountsController : ControllerBase
|
public class AccountsController : ControllerBase
|
||||||
{
|
{
|
||||||
[HttpGet("me")]
|
[HttpGet("account/me")]
|
||||||
[Authorize]
|
[Authorize]
|
||||||
public async Task<IResult> Me(AppDbContext db)
|
public async Task<IResult> Me(AppDbContext db)
|
||||||
{
|
{
|
||||||
@@ -18,9 +18,10 @@ public class AccountsController : ControllerBase
|
|||||||
|
|
||||||
Account? account = await db.Accounts.FindAsync(id);
|
Account? account = await db.Accounts.FindAsync(id);
|
||||||
if (account == null)
|
if (account == null)
|
||||||
return Results.NotFound();
|
return Results.Unauthorized();
|
||||||
|
|
||||||
SelfAccount selfAccount = new SelfAccount {
|
SelfAccount selfAccount = new SelfAccount
|
||||||
|
{
|
||||||
AccountId = id,
|
AccountId = id,
|
||||||
ProfileImage = account.ProfileImage ?? "hdqeamlcmatc6qzoi2ybgf0ddijjcf.jpg",
|
ProfileImage = account.ProfileImage ?? "hdqeamlcmatc6qzoi2ybgf0ddijjcf.jpg",
|
||||||
IsJunior = account.IsJunior,
|
IsJunior = account.IsJunior,
|
||||||
@@ -41,7 +42,7 @@ public class AccountsController : ControllerBase
|
|||||||
return Results.Ok(selfAccount);
|
return Results.Ok(selfAccount);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("bulk")]
|
[HttpGet("account/bulk")]
|
||||||
public async Task<IResult> Bulk(AppDbContext db)
|
public async Task<IResult> Bulk(AppDbContext db)
|
||||||
{
|
{
|
||||||
StringValues ids = HttpContext.Request.Query["id"];
|
StringValues ids = HttpContext.Request.Query["id"];
|
||||||
@@ -73,7 +74,7 @@ public class AccountsController : ControllerBase
|
|||||||
return Results.Json(result);
|
return Results.Json(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("{id}")]
|
[HttpGet("account/{id}")]
|
||||||
public async Task<IResult> Id(string id, AppDbContext db)
|
public async Task<IResult> Id(string id, AppDbContext db)
|
||||||
{
|
{
|
||||||
if (!int.TryParse(id, out int accountId))
|
if (!int.TryParse(id, out int accountId))
|
||||||
@@ -99,7 +100,7 @@ public class AccountsController : ControllerBase
|
|||||||
return Results.Json(result);
|
return Results.Json(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("create")]
|
[HttpPost("account/create")]
|
||||||
public async Task<IResult> Create(AppDbContext db)
|
public async Task<IResult> Create(AppDbContext db)
|
||||||
{
|
{
|
||||||
var request = HttpContext.Request;
|
var request = HttpContext.Request;
|
||||||
|
|||||||
@@ -4,109 +4,114 @@ using Microsoft.AspNetCore.Mvc;
|
|||||||
|
|
||||||
namespace CannedNet.Services.Controllers;
|
namespace CannedNet.Services.Controllers;
|
||||||
|
|
||||||
[ApiController]
|
[ApiController, Route("auth")]
|
||||||
public class AuthController : ControllerBase
|
public class AuthController : ControllerBase
|
||||||
{
|
{
|
||||||
[HttpGet("eac/challenge")]
|
[HttpGet("eac/challenge")]
|
||||||
public async Task<IResult> EacChallenge() {
|
public async Task<IResult> EacChallenge()
|
||||||
|
{
|
||||||
string file = await System.IO.File.ReadAllTextAsync("JSON/eacchallenge.txt");
|
string file = await System.IO.File.ReadAllTextAsync("JSON/eacchallenge.txt");
|
||||||
return Results.Content(file, "text/plain");
|
return Results.Content(file, "text/plain");
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("cachedlogin/forplatformid/{platform}/{id}")]
|
[HttpGet("cachedlogin/forplatformid/{platform}/{id}")]
|
||||||
public async Task<IResult> CachedLoginForPlatformId(string platform, string id, AppDbContext db) {
|
public async Task<IResult> CachedLoginForPlatformId(string platform, string id, AppDbContext db)
|
||||||
|
{
|
||||||
int platformType = int.Parse(platform);
|
int platformType = int.Parse(platform);
|
||||||
List<CachedLogin> logins = await db.CachedLogins
|
List<CachedLogin> logins = await db.CachedLogins
|
||||||
.Where(c => c.Platform == (PlatformType)platformType && c.PlatformID == id)
|
.Where(c => c.Platform == (PlatformType)platformType && c.PlatformID == id)
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
return Results.Json(logins.Any() ? logins : new List<object>());
|
return Results.Json(logins.Any() ? logins : new List<object>());
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("connect/token")]
|
[HttpPost("connect/token")]
|
||||||
public async Task<IResult> ConnectToken(AppDbContext db, JwtTokenService jwtService) {
|
public async Task<IResult> ConnectToken(AppDbContext db, JwtTokenService jwtService)
|
||||||
string accountId = "";
|
{
|
||||||
string platformId = "";
|
string accountId = "";
|
||||||
string platform = "";
|
string platformId = "";
|
||||||
|
string platform = "";
|
||||||
|
|
||||||
if (HttpContext.Request.ContentLength is > 0)
|
if (HttpContext.Request.ContentLength is > 0)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
try
|
HttpContext.Request.EnableBuffering();
|
||||||
{
|
using StreamReader reader = new(HttpContext.Request.Body, leaveOpen: true);
|
||||||
HttpContext.Request.EnableBuffering();
|
string body = await reader.ReadToEndAsync();
|
||||||
using StreamReader reader = new (HttpContext.Request.Body, leaveOpen: true);
|
|
||||||
string body = await reader.ReadToEndAsync();
|
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(body))
|
|
||||||
{
|
|
||||||
foreach (string pair in body.Split('&'))
|
|
||||||
{
|
|
||||||
string[] keyValue = pair.Split('=');
|
|
||||||
if (keyValue.Length != 2) continue;
|
|
||||||
string key = Uri.UnescapeDataString(keyValue[0]);
|
|
||||||
string value = Uri.UnescapeDataString(keyValue[1]);
|
|
||||||
|
|
||||||
switch (key) {
|
if (!string.IsNullOrWhiteSpace(body))
|
||||||
case "account_id":
|
{
|
||||||
accountId = value;
|
foreach (string pair in body.Split('&'))
|
||||||
break;
|
{
|
||||||
case "platform_id":
|
string[] keyValue = pair.Split('=');
|
||||||
platformId = value;
|
if (keyValue.Length != 2) continue;
|
||||||
break;
|
string key = Uri.UnescapeDataString(keyValue[0]);
|
||||||
}
|
string value = Uri.UnescapeDataString(keyValue[1]);
|
||||||
|
|
||||||
|
switch (key)
|
||||||
|
{
|
||||||
|
case "account_id":
|
||||||
|
accountId = value;
|
||||||
|
break;
|
||||||
|
case "platform_id":
|
||||||
|
platformId = value;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
HttpContext.Request.Body.Position = 0;
|
|
||||||
}
|
}
|
||||||
catch { }
|
HttpContext.Request.Body.Position = 0;
|
||||||
}
|
}
|
||||||
|
catch { }
|
||||||
|
}
|
||||||
|
|
||||||
string accessToken = jwtService.GenerateToken(accountId, platformId, platform);
|
string accessToken = jwtService.GenerateToken(accountId, platformId, platform);
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(accountId) && int.TryParse(accountId, out var id))
|
if (!string.IsNullOrEmpty(accountId) && int.TryParse(accountId, out var id))
|
||||||
|
{
|
||||||
|
RoomInstance? roomInstance = await db.RoomInstances.FirstOrDefaultAsync(r => r.OwnerAccountId == id);
|
||||||
|
if (roomInstance != null)
|
||||||
{
|
{
|
||||||
RoomInstance? roomInstance = await db.RoomInstances.FirstOrDefaultAsync(r => r.OwnerAccountId == id);
|
db.RoomInstances.Remove(roomInstance);
|
||||||
if (roomInstance != null)
|
await db.SaveChangesAsync();
|
||||||
{
|
|
||||||
db.RoomInstances.Remove(roomInstance);
|
|
||||||
await db.SaveChangesAsync();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return Results.Json(new
|
return Results.Json(new
|
||||||
{
|
{
|
||||||
access_token = accessToken,
|
access_token = accessToken,
|
||||||
expires_in = 3600,
|
expires_in = 3600,
|
||||||
token_type = "Bearer",
|
token_type = "Bearer",
|
||||||
refresh_token = Guid.NewGuid().ToString("N").ToUpper() + "-1",
|
refresh_token = Guid.NewGuid().ToString("N").ToUpper() + "-1",
|
||||||
scope = "offline_access profile rn rn.accounts rn.accounts.gc rn.api rn.chat rn.clubs rn.commerce rn.match.read rn.match.write rn.notify rn.rooms rn.storage",
|
scope = "offline_access profile rn rn.accounts rn.accounts.gc rn.api rn.chat rn.clubs rn.commerce rn.match.read rn.match.write rn.notify rn.rooms rn.storage",
|
||||||
key = "8oQ+e+WQaOBPbEcakhqs3dwZZdOmmyDUmJSD9u4AHMY="
|
key = "8oQ+e+WQaOBPbEcakhqs3dwZZdOmmyDUmJSD9u4AHMY="
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("api/accounts/v1/forplatformids")]
|
[HttpPost("api/accounts/v1/forplatformids")]
|
||||||
public async Task<IResult> AccountsForPlatformIds(AppDbContext db) {
|
public async Task<IResult> AccountsForPlatformIds(AppDbContext db)
|
||||||
|
{
|
||||||
|
|
||||||
HttpContext.Request.EnableBuffering();
|
HttpContext.Request.EnableBuffering();
|
||||||
HttpContext.Request.Body.Position = 0;
|
HttpContext.Request.Body.Position = 0;
|
||||||
using var reader = new StreamReader(HttpContext.Request.Body);
|
using var reader = new StreamReader(HttpContext.Request.Body);
|
||||||
string body = await reader.ReadToEndAsync();
|
string body = await reader.ReadToEndAsync();
|
||||||
|
|
||||||
List<string> ids = [];
|
List<string> ids = [];
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(body))
|
if (!string.IsNullOrWhiteSpace(body))
|
||||||
{
|
{
|
||||||
foreach (string pair in body.Split('&'))
|
foreach (string pair in body.Split('&'))
|
||||||
{
|
{
|
||||||
string[] keyValue = pair.Split('=');
|
string[] keyValue = pair.Split('=');
|
||||||
if (keyValue.Length != 2 || keyValue[0] != "Ids") continue;
|
if (keyValue.Length != 2 || keyValue[0] != "Ids") continue;
|
||||||
|
|
||||||
string idString = Uri.UnescapeDataString(keyValue[1]);
|
string idString = Uri.UnescapeDataString(keyValue[1]);
|
||||||
ids = idString.Split(',').ToList();
|
ids = idString.Split(',').ToList();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
List<object> results = [];
|
List<object> results = [];
|
||||||
foreach (string platformId in ids)
|
foreach (string platformId in ids)
|
||||||
{
|
{
|
||||||
@@ -116,12 +121,13 @@ public class AuthController : ControllerBase
|
|||||||
results.Add(new { accountId = cachedLogin.AccountId, platformId = platformId });
|
results.Add(new { accountId = cachedLogin.AccountId, platformId = platformId });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Results.Json(results);
|
return Results.Json(results);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("role/developer/{id}")]
|
[HttpGet("role/developer/{id}")]
|
||||||
public async Task<IResult> GetDeveloperRole(string id) {
|
public async Task<IResult> GetDeveloperRole(string id)
|
||||||
|
{
|
||||||
return Results.Ok(RecNetResult.Ok());
|
return Results.Ok(RecNetResult.Ok());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,21 +9,60 @@ namespace CannedNet.Services.Controllers;
|
|||||||
[ApiController, Route("econ")]
|
[ApiController, Route("econ")]
|
||||||
public class EconController : ControllerBase
|
public class EconController : ControllerBase
|
||||||
{
|
{
|
||||||
[HttpGet("/api/avatar/v1/defaultunlocked")]
|
[HttpGet("customAvatarItems/v1/owned")]
|
||||||
|
public async Task<IResult> CustomAvatarItemsOwned()
|
||||||
|
{
|
||||||
|
return Results.Json(new { items = new List<object>() });
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("api/avatar/v1/defaultunlocked")]
|
||||||
public async Task<IResult> DefaultUnlocked()
|
public async Task<IResult> DefaultUnlocked()
|
||||||
{
|
{
|
||||||
var json = System.IO.File.ReadAllText("JSON/defaultAvatarItems.json");
|
var json = System.IO.File.ReadAllText("JSON/defaultAvatarItems.json");
|
||||||
return Results.Content(json, "application/json");
|
return Results.Content(json, "application/json");
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("/api/avatar/v1/defaultbaseavataritems")]
|
[HttpGet("api/objectives/v1/myprogress")]
|
||||||
public async Task<IResult> DefaultBaseAvatarItems()
|
public async Task<IResult> ObjectivesMyProgress()
|
||||||
{
|
{
|
||||||
var json = System.IO.File.ReadAllText("JSON/defaultAvatarItems.json");
|
var json = System.IO.File.ReadAllText("JSON/tempmyprogress.json");
|
||||||
return Results.Content(json, "application/json");
|
return Results.Content(json, "application/json");
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("/api/avatar/v4/items")]
|
[HttpGet("api/avatar/v2")]
|
||||||
|
[Authorize]
|
||||||
|
public async Task<IResult> GetAvatarV2(AppDbContext db)
|
||||||
|
{
|
||||||
|
if (!int.TryParse(User.Identity?.Name, 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 = "",
|
||||||
|
FaceFeatures = "{}",
|
||||||
|
SkinColor = "",
|
||||||
|
HairColor = ""
|
||||||
|
};
|
||||||
|
db.PlayerAvatars.Add(avatar);
|
||||||
|
await db.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
return Results.Json(new
|
||||||
|
{
|
||||||
|
OutfitSelections = avatar.OutfitSelections,
|
||||||
|
FaceFeatures = avatar.FaceFeatures,
|
||||||
|
SkinColor = avatar.SkinColor,
|
||||||
|
HairColor = avatar.HairColor
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("api/avatar/v4/items")]
|
||||||
[Authorize]
|
[Authorize]
|
||||||
public async Task<IResult> GetAvatarItemsV4(AppDbContext db)
|
public async Task<IResult> GetAvatarItemsV4(AppDbContext db)
|
||||||
{
|
{
|
||||||
@@ -196,241 +235,10 @@ public class EconController : ControllerBase
|
|||||||
return Results.Json(allItems);
|
return Results.Json(allItems);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("api/objectives/v1/myprogress")]
|
[HttpGet("api/avatar/v1/defaultbaseavataritems")]
|
||||||
public async Task<IResult> ObjectivesMyProgress()
|
public async Task<IResult> DefaultBaseAvatarItems()
|
||||||
{
|
{
|
||||||
var json = System.IO.File.ReadAllText("JSON/tempmyprogress.json");
|
var json = System.IO.File.ReadAllText("JSON/defaultAvatarItems.json");
|
||||||
return Results.Content(json, "application/json");
|
return Results.Content(json, "application/json");
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("api/avatar/v2")]
|
|
||||||
[Authorize]
|
|
||||||
public async Task<IResult> GetAvatarV2(AppDbContext db)
|
|
||||||
{
|
|
||||||
if (!int.TryParse(User.Identity?.Name, 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 = "",
|
|
||||||
FaceFeatures = "{}",
|
|
||||||
SkinColor = "",
|
|
||||||
HairColor = ""
|
|
||||||
};
|
|
||||||
db.PlayerAvatars.Add(avatar);
|
|
||||||
await db.SaveChangesAsync();
|
|
||||||
}
|
|
||||||
|
|
||||||
return Results.Json(new
|
|
||||||
{
|
|
||||||
OutfitSelections = avatar.OutfitSelections,
|
|
||||||
FaceFeatures = avatar.FaceFeatures,
|
|
||||||
SkinColor = avatar.SkinColor,
|
|
||||||
HairColor = avatar.HairColor
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpPost("api/settings/v2/set")]
|
|
||||||
[Authorize]
|
|
||||||
public async Task<IResult> SetSettings(AppDbContext db)
|
|
||||||
{
|
|
||||||
if (!int.TryParse(User.Identity?.Name, out var id))
|
|
||||||
return Results.Unauthorized();
|
|
||||||
|
|
||||||
HttpContext.Request.EnableBuffering();
|
|
||||||
HttpContext.Request.Body.Position = 0;
|
|
||||||
using var reader = new StreamReader(HttpContext.Request.Body);
|
|
||||||
var body = await reader.ReadToEndAsync();
|
|
||||||
|
|
||||||
Console.WriteLine($"Settings request body: {body}");
|
|
||||||
|
|
||||||
var settings = new List<PlayerSetting>();
|
|
||||||
|
|
||||||
if (body.TrimStart().StartsWith("["))
|
|
||||||
{
|
|
||||||
settings = System.Text.Json.JsonSerializer.Deserialize<List<PlayerSetting>>(body) ?? [];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var single = System.Text.Json.JsonSerializer.Deserialize<PlayerSetting>(body);
|
|
||||||
if (single != null) settings.Add(single);
|
|
||||||
}
|
|
||||||
|
|
||||||
settings = settings.Where(s => !string.IsNullOrEmpty(s.Key)).ToList();
|
|
||||||
|
|
||||||
if (!settings.Any())
|
|
||||||
return Results.Ok();
|
|
||||||
|
|
||||||
db.PlayerSettings.RemoveRange(db.PlayerSettings.Where(s => s.PlayerId == id));
|
|
||||||
|
|
||||||
foreach (var setting in settings)
|
|
||||||
{
|
|
||||||
setting.PlayerId = id;
|
|
||||||
setting.Key = setting.Key ?? "";
|
|
||||||
setting.Value = setting.Value ?? "";
|
|
||||||
db.PlayerSettings.Add(setting);
|
|
||||||
}
|
|
||||||
|
|
||||||
await db.SaveChangesAsync();
|
|
||||||
return Results.Ok();
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpGet("econ/customAvatarItems/v1/owned")]
|
|
||||||
public async Task<IResult> CustomAvatarItemsOwned()
|
|
||||||
{
|
|
||||||
return Results.Json(new { items = new List<object>() });
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpGet("api/equipment/v2/getUnlocked")]
|
|
||||||
public async Task<IResult> GetEquipmentUnlocked()
|
|
||||||
{
|
|
||||||
return Results.Content("[]", "application/json");
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpGet("api/consumables/v2/getUnlocked")]
|
|
||||||
[Authorize]
|
|
||||||
public async Task<IResult> GetConsumablesUnlocked(AppDbContext db)
|
|
||||||
{
|
|
||||||
if (!int.TryParse(User.Identity?.Name, out var id))
|
|
||||||
return Results.Unauthorized();
|
|
||||||
|
|
||||||
var consumables = await db.ConsumableItems
|
|
||||||
.Where(c => c.OwnerAccountId == id)
|
|
||||||
.ToListAsync();
|
|
||||||
|
|
||||||
return Results.Json(consumables);
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpGet("api/storefronts/v4/balance/2")]
|
|
||||||
[Authorize]
|
|
||||||
public async Task<IResult> GetStorefrontBalance(AppDbContext db)
|
|
||||||
{
|
|
||||||
if (!int.TryParse(User.Identity?.Name, out var id))
|
|
||||||
return Results.Unauthorized();
|
|
||||||
|
|
||||||
var balance = await db.TokenBalances
|
|
||||||
.Where(s => s.Id == id)
|
|
||||||
.ToListAsync();
|
|
||||||
|
|
||||||
return Results.Json(balance);
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpGet("api/storefronts/v3/giftdropstore/3")]
|
|
||||||
public async Task<IResult> GetGiftDropStore3(AppDbContext db, StorefrontFillService storefrontService)
|
|
||||||
{
|
|
||||||
var storefronts = await storefrontService.GetStorefrontsAsync();
|
|
||||||
var storefront = storefronts.FirstOrDefault(s => s.StorefrontType == 2 && s.Name == "watch_store");
|
|
||||||
if (storefront == null)
|
|
||||||
{
|
|
||||||
var json = System.IO.File.ReadAllText("JSON/storefront3.json");
|
|
||||||
return Results.Content(json, "application/json");
|
|
||||||
}
|
|
||||||
var storeItems = storefront.Items.Select(item => new
|
|
||||||
{
|
|
||||||
item.Id,
|
|
||||||
item.StorefrontId,
|
|
||||||
item.PurchasableItemId,
|
|
||||||
item.Type,
|
|
||||||
item.IsFeatured,
|
|
||||||
item.NewUntil,
|
|
||||||
GiftDrops = item.GiftDrops.Select(gd => new
|
|
||||||
{
|
|
||||||
gd.Id,
|
|
||||||
gd.StorefrontItemId,
|
|
||||||
gd.GiftDropId,
|
|
||||||
gd.FriendlyName,
|
|
||||||
gd.Tooltip,
|
|
||||||
gd.ConsumableItemDesc,
|
|
||||||
gd.AvatarItemDesc,
|
|
||||||
gd.AvatarItemType,
|
|
||||||
gd.EquipmentPrefabName,
|
|
||||||
gd.EquipmentModificationGuid,
|
|
||||||
gd.IsQuery,
|
|
||||||
gd.Unique,
|
|
||||||
gd.SubscribersOnly,
|
|
||||||
gd.Level,
|
|
||||||
gd.Rarity,
|
|
||||||
gd.CurrencyType,
|
|
||||||
gd.Currency,
|
|
||||||
gd.Context,
|
|
||||||
gd.ItemSetId,
|
|
||||||
gd.ItemSetFriendlyName
|
|
||||||
}).ToList(),
|
|
||||||
Prices = item.Prices.Select(p => new
|
|
||||||
{
|
|
||||||
p.Id,
|
|
||||||
p.StorefrontItemId,
|
|
||||||
p.CurrencyType,
|
|
||||||
p.Price
|
|
||||||
}).ToList()
|
|
||||||
}).ToList();
|
|
||||||
var response = new { storefront.Id, storefront.Name, storefront.StorefrontType, storefront.NextUpdate, StoreItems = storeItems };
|
|
||||||
return Results.Ok(response);
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpGet("api/challenge/v2/getCurrent")]
|
|
||||||
public async Task<IResult> GetCurrentChallenge()
|
|
||||||
{
|
|
||||||
var json = System.IO.File.ReadAllText("JSON/weeklychallenge.json");
|
|
||||||
return Results.Content(json, "application/json");
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpGet("api/avatar/v3/saved")]
|
|
||||||
[Authorize]
|
|
||||||
public async Task<IResult> GetSavedAvatars(AppDbContext db)
|
|
||||||
{
|
|
||||||
if (!int.TryParse(User.Identity?.Name, out var id))
|
|
||||||
return Results.Unauthorized();
|
|
||||||
|
|
||||||
var items = await db.SavedOutfits
|
|
||||||
.Where(i => i.OwnerAccountId == id)
|
|
||||||
.ToListAsync();
|
|
||||||
|
|
||||||
return Results.Json(items);
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpGet("api/avatar/v2/gifts")]
|
|
||||||
[Authorize]
|
|
||||||
public async Task<IResult> GetGifts(AppDbContext db)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (!int.TryParse(User.Identity?.Name, out var id))
|
|
||||||
return Results.Unauthorized();
|
|
||||||
|
|
||||||
var pendingGifts = await db.ReceivedGifts
|
|
||||||
.Where(rg => rg.ReceiverAccountId == id && !rg.IsConsumed)
|
|
||||||
.ToListAsync();
|
|
||||||
|
|
||||||
return Results.Json(pendingGifts);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
return Results.Problem($"Error retrieving gifts: {ex.Message}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpGet("api/gamerewards/v1/pending")]
|
|
||||||
public async Task<IResult> GetGameRewardsPending()
|
|
||||||
{
|
|
||||||
return Results.Content("[]", "application/json");
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpGet("api/roomkeys/v1/mine")]
|
|
||||||
public async Task<IResult> GetRoomKeysMine()
|
|
||||||
{
|
|
||||||
return Results.Content("[]", "application/json");
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpPost("api/CampusCard/v1/UpdateAndGetSubscription")]
|
|
||||||
public async Task<IResult> UpdateAndGetSubscription()
|
|
||||||
{
|
|
||||||
return Results.Json(new { subscription = (object?)null, platformAccountSubscribedPlayerId = (object?)null });
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,14 +28,14 @@ public class MatchmakingController : ControllerBase
|
|||||||
var id = HttpContext.Request.Query["id"].FirstOrDefault();
|
var id = HttpContext.Request.Query["id"].FirstOrDefault();
|
||||||
if (string.IsNullOrEmpty(id) || !int.TryParse(id, out var accountId))
|
if (string.IsNullOrEmpty(id) || !int.TryParse(id, out var accountId))
|
||||||
{
|
{
|
||||||
var json = System.IO.File.ReadAllText("JSON/getplayer.json");
|
var json = System.IO.File.ReadAllText("JSON/getplayer.json");
|
||||||
return Results.Content(json, "application/json");
|
return Results.Content(json, "application/json");
|
||||||
}
|
}
|
||||||
|
|
||||||
var account = await db.Accounts.FindAsync(accountId);
|
var account = await db.Accounts.FindAsync(accountId);
|
||||||
if (account == null)
|
if (account == null)
|
||||||
{
|
{
|
||||||
var json = System.IO.File.ReadAllText("JSON/getplayer.json");
|
var json = System.IO.File.ReadAllText("JSON/getplayer.json");
|
||||||
return Results.Content(json, "application/json");
|
return Results.Content(json, "application/json");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user