mirror of
https://github.com/CannedNet/CannedNet.git
synced 2026-10-25 23:18:54 -07:00
fixed rooms + various endpoints
This commit is contained in:
@@ -547,7 +547,6 @@ public class APIService
|
|||||||
});
|
});
|
||||||
app.MapPost("/api/CampusCard/v1/UpdateAndGetSubscription", async (HttpRequest request, AppDbContext db) =>
|
app.MapPost("/api/CampusCard/v1/UpdateAndGetSubscription", async (HttpRequest request, AppDbContext db) =>
|
||||||
{
|
{
|
||||||
// TODO ADD FUNCTIONALITY
|
|
||||||
return Results.Json(new { subscription = (object?)null, platformAccountSubscribedPlayerId = (object?)null });
|
return Results.Json(new { subscription = (object?)null, platformAccountSubscribedPlayerId = (object?)null });
|
||||||
});
|
});
|
||||||
app.MapGet("/api/storefronts/v4/balance/2", async (HttpRequest request, AppDbContext db) =>
|
app.MapGet("/api/storefronts/v4/balance/2", async (HttpRequest request, AppDbContext db) =>
|
||||||
@@ -580,6 +579,58 @@ public class APIService
|
|||||||
var roomid = request.Query["roomId"];
|
var roomid = request.Query["roomId"];
|
||||||
return "[]";
|
return "[]";
|
||||||
});
|
});
|
||||||
|
app.MapGet("/api/accounts/v1/getBio", async (HttpRequest request, AppDbContext db) =>
|
||||||
|
{
|
||||||
|
// TODO: store bio's in db
|
||||||
|
|
||||||
|
var authHeader = request.Headers.Authorization.ToString();
|
||||||
|
|
||||||
|
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) || !int.TryParse(accountId.AsSpan(), out var id))
|
||||||
|
return Results.Unauthorized();
|
||||||
|
|
||||||
|
return Results.Json(new { accountId = id, bio = "" });
|
||||||
|
});
|
||||||
|
app.MapPost("/api/accounts/v1/forplatformids", async (HttpRequest request, AppDbContext db) =>
|
||||||
|
{
|
||||||
|
request.EnableBuffering();
|
||||||
|
request.Body.Position = 0;
|
||||||
|
using var reader = new StreamReader(request.Body);
|
||||||
|
var body = await reader.ReadToEndAsync();
|
||||||
|
|
||||||
|
var ids = new List<string>();
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(body))
|
||||||
|
{
|
||||||
|
foreach (var pair in body.Split('&'))
|
||||||
|
{
|
||||||
|
var keyValue = pair.Split('=');
|
||||||
|
if (keyValue.Length == 2 && keyValue[0] == "Ids")
|
||||||
|
{
|
||||||
|
var idString = Uri.UnescapeDataString(keyValue[1]);
|
||||||
|
ids = idString.Split(',').ToList();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var results = new List<object>();
|
||||||
|
foreach (var platformId in ids)
|
||||||
|
{
|
||||||
|
var cachedLogin = await db.CachedLogins.FirstOrDefaultAsync(c => c.PlatformID == platformId);
|
||||||
|
if (cachedLogin != null)
|
||||||
|
{
|
||||||
|
results.Add(new { accountId = cachedLogin.AccountId, platformId = platformId });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Results.Json(results);
|
||||||
|
});
|
||||||
app.MapGet("/api/storefronts/v3/giftdropstore/3", async (HttpRequest request, AppDbContext db) =>
|
app.MapGet("/api/storefronts/v3/giftdropstore/3", async (HttpRequest request, AppDbContext db) =>
|
||||||
{
|
{
|
||||||
var json = File.ReadAllText("JSON/storefront3.json");
|
var json = File.ReadAllText("JSON/storefront3.json");
|
||||||
|
|||||||
@@ -188,5 +188,63 @@ public class AccountsService
|
|||||||
|
|
||||||
return Results.Content($"{{\"accountId\":{accountId},\"disallowInAppPurchases\":false}}", "application/json");
|
return Results.Content($"{{\"accountId\":{accountId},\"disallowInAppPurchases\":false}}", "application/json");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
app.MapPut("/account/me/displayname", async (HttpRequest request, AppDbContext db) =>
|
||||||
|
{
|
||||||
|
// TODO: get what the server should actually respond with, OK fails.
|
||||||
|
|
||||||
|
var authHeader = request.Headers.Authorization.ToString();
|
||||||
|
|
||||||
|
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();
|
||||||
|
|
||||||
|
string newDisplayName = "";
|
||||||
|
|
||||||
|
if (request.ContentLength.HasValue && request.ContentLength > 0)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
request.EnableBuffering();
|
||||||
|
using var reader = new StreamReader(request.Body, leaveOpen: true);
|
||||||
|
var body = await reader.ReadToEndAsync();
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(body))
|
||||||
|
{
|
||||||
|
foreach (var pair in body.Split('&'))
|
||||||
|
{
|
||||||
|
var keyValue = pair.Split('=');
|
||||||
|
if (keyValue.Length == 2)
|
||||||
|
{
|
||||||
|
var key = Uri.UnescapeDataString(keyValue[0]);
|
||||||
|
var value = Uri.UnescapeDataString(keyValue[1]);
|
||||||
|
|
||||||
|
if (key == "displayName")
|
||||||
|
newDisplayName = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
request.Body.Position = 0;
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
}
|
||||||
|
|
||||||
|
var account = await db.Accounts.FindAsync(id);
|
||||||
|
if (account == null)
|
||||||
|
return Results.NotFound();
|
||||||
|
|
||||||
|
account.DisplayName = newDisplayName;
|
||||||
|
await db.SaveChangesAsync();
|
||||||
|
|
||||||
|
return Results.Ok();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ public class MatchmakingService
|
|||||||
|
|
||||||
if (!int.TryParse(accountId.AsSpan(), out var id))
|
if (!int.TryParse(accountId.AsSpan(), out var id))
|
||||||
return Results.Unauthorized();
|
return Results.Unauthorized();
|
||||||
|
|
||||||
Room? roomData = null;
|
Room? roomData = null;
|
||||||
var roomLower = room.ToLower();
|
var roomLower = room.ToLower();
|
||||||
|
|
||||||
@@ -100,7 +100,7 @@ public class MatchmakingService
|
|||||||
{
|
{
|
||||||
photonRoomId = Guid.NewGuid().ToString();
|
photonRoomId = Guid.NewGuid().ToString();
|
||||||
|
|
||||||
var existingInstance = await db.RoomInstances.FirstOrDefaultAsync(r => r.OwnerAccountId == id);
|
var existingInstance = await db.RoomInstances.FirstOrDefaultAsync(r => r.OwnerAccountId == id && r.roomId == roomData.RoomId);
|
||||||
|
|
||||||
if (existingInstance != null)
|
if (existingInstance != null)
|
||||||
{
|
{
|
||||||
@@ -270,7 +270,7 @@ public class MatchmakingService
|
|||||||
isInProgress = roomInstance.isInProgress,
|
isInProgress = roomInstance.isInProgress,
|
||||||
EncryptVoiceChat = roomInstance.EncryptVoiceChat
|
EncryptVoiceChat = roomInstance.EncryptVoiceChat
|
||||||
} : null,
|
} : null,
|
||||||
isOnline = roomInstance != null && roomInstance.roomId != 1,
|
isOnline = roomInstance != null,
|
||||||
appVersion = heartbeat.appVersion ?? "",
|
appVersion = heartbeat.appVersion ?? "",
|
||||||
platform = heartbeat.platform
|
platform = heartbeat.platform
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user