various endpoints

scuffed for the time being, will be fixed later
This commit is contained in:
mia
2026-04-01 10:31:57 -04:00
parent a2d6b04524
commit bef77babde
8 changed files with 495 additions and 0 deletions
+1
View File
@@ -5,6 +5,7 @@
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<RootNamespace>CannedNet</RootNamespace> <RootNamespace>CannedNet</RootNamespace>
<AllowMissingPrunePackageData>true</AllowMissingPrunePackageData>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
+11
View File
@@ -14,6 +14,7 @@ public class AppDbContext : DbContext
public DbSet<PlayerSetting> PlayerSettings { get; set; } public DbSet<PlayerSetting> PlayerSettings { get; set; }
public DbSet<AvatarItem> AvatarItems { get; set; } public DbSet<AvatarItem> AvatarItems { get; set; }
public DbSet<PlayerAvatar> PlayerAvatars { get; set; } public DbSet<PlayerAvatar> PlayerAvatars { get; set; }
public DbSet<SavedOutfit> SavedOutfits { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder) protected override void OnModelCreating(ModelBuilder modelBuilder)
{ {
@@ -80,6 +81,16 @@ public class AppDbContext : DbContext
entity.HasIndex(e => e.OwnerAccountId).IsUnique(); entity.HasIndex(e => e.OwnerAccountId).IsUnique();
entity.ToTable("player_avatars"); entity.ToTable("player_avatars");
}); });
// saved_outfits
modelBuilder.Entity<SavedOutfit>(entity =>
{
entity.HasKey(e => e.Id);
entity.Property(e => e.Id).ValueGeneratedOnAdd();
entity.Property(e => e.OwnerAccountId).IsRequired();
entity.HasIndex(e => e.OwnerAccountId).IsUnique();
entity.ToTable("saved_outfits");
});
} }
} }
@@ -0,0 +1,302 @@
// <auto-generated />
using System;
using CannedNet.Data;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace CannedNet.Migrations
{
[DbContext(typeof(AppDbContext))]
[Migration("20260401141417_AddSavedOutfits")]
partial class AddSavedOutfits
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.0")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("CannedNet.Account", b =>
{
b.Property<int?>("AccountId")
.HasColumnType("integer")
.HasAnnotation("Relational:JsonPropertyName", "accountId");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp with time zone")
.HasAnnotation("Relational:JsonPropertyName", "createdAt");
b.Property<string>("DisplayName")
.IsRequired()
.HasColumnType("text")
.HasAnnotation("Relational:JsonPropertyName", "displayName");
b.Property<int?>("IdentityFlags")
.HasColumnType("integer")
.HasAnnotation("Relational:JsonPropertyName", "identityFlags");
b.Property<bool>("IsJunior")
.HasColumnType("boolean")
.HasAnnotation("Relational:JsonPropertyName", "isJunior");
b.Property<int?>("PersonalPronouns")
.HasColumnType("integer")
.HasAnnotation("Relational:JsonPropertyName", "personalPronouns");
b.Property<int?>("Platforms")
.HasColumnType("integer")
.HasAnnotation("Relational:JsonPropertyName", "platforms");
b.Property<string>("ProfileImage")
.HasColumnType("text")
.HasAnnotation("Relational:JsonPropertyName", "profileImage");
b.Property<string>("Username")
.IsRequired()
.HasColumnType("text")
.HasAnnotation("Relational:JsonPropertyName", "username");
b.HasKey("AccountId");
b.ToTable("accounts", (string)null);
});
modelBuilder.Entity("CannedNet.AvatarItem", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("AvatarItemDesc")
.IsRequired()
.HasColumnType("text")
.HasAnnotation("Relational:JsonPropertyName", "avatarItemDesc");
b.Property<int>("AvatarItemType")
.HasColumnType("integer")
.HasAnnotation("Relational:JsonPropertyName", "avatarItemType");
b.Property<string>("FriendlyName")
.IsRequired()
.HasColumnType("text")
.HasAnnotation("Relational:JsonPropertyName", "friendlyName");
b.Property<int>("OwnerAccountId")
.HasColumnType("integer");
b.Property<int>("PlatformMask")
.HasColumnType("integer")
.HasAnnotation("Relational:JsonPropertyName", "platformMask");
b.Property<int>("Rarity")
.HasColumnType("integer")
.HasAnnotation("Relational:JsonPropertyName", "rarity");
b.Property<string>("Tooltip")
.IsRequired()
.HasColumnType("text")
.HasAnnotation("Relational:JsonPropertyName", "tooltip");
b.HasKey("Id");
b.HasIndex("OwnerAccountId");
b.ToTable("avatar_items", (string)null);
});
modelBuilder.Entity("CannedNet.CachedLogin", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("AccountId")
.HasColumnType("integer")
.HasAnnotation("Relational:JsonPropertyName", "accountId");
b.Property<DateTime>("LastLoginTime")
.HasColumnType("timestamp with time zone")
.HasAnnotation("Relational:JsonPropertyName", "lastLoginTime");
b.Property<int>("Platform")
.HasColumnType("integer")
.HasAnnotation("Relational:JsonPropertyName", "platform");
b.Property<string>("PlatformID")
.IsRequired()
.HasColumnType("text")
.HasAnnotation("Relational:JsonPropertyName", "platformId");
b.Property<bool>("RequirePassword")
.HasColumnType("boolean")
.HasAnnotation("Relational:JsonPropertyName", "requirePassword");
b.HasKey("Id");
b.HasIndex("Platform", "PlatformID")
.IsUnique();
b.ToTable("cached_logins", (string)null);
});
modelBuilder.Entity("CannedNet.PlayerAvatar", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("FaceFeatures")
.IsRequired()
.HasColumnType("text")
.HasAnnotation("Relational:JsonPropertyName", "FaceFeatures");
b.Property<string>("HairColor")
.IsRequired()
.HasColumnType("text")
.HasAnnotation("Relational:JsonPropertyName", "HairColor");
b.Property<string>("OutfitSelections")
.IsRequired()
.HasColumnType("text")
.HasAnnotation("Relational:JsonPropertyName", "OutfitSelections");
b.Property<int>("OwnerAccountId")
.HasColumnType("integer");
b.Property<string>("SkinColor")
.IsRequired()
.HasColumnType("text")
.HasAnnotation("Relational:JsonPropertyName", "SkinColor");
b.HasKey("Id");
b.HasIndex("OwnerAccountId")
.IsUnique();
b.ToTable("player_avatars", (string)null);
});
modelBuilder.Entity("CannedNet.PlayerProgression", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("Level")
.HasColumnType("integer")
.HasAnnotation("Relational:JsonPropertyName", "level");
b.Property<int>("PlayerId")
.HasColumnType("integer")
.HasAnnotation("Relational:JsonPropertyName", "playerId");
b.Property<int>("Xp")
.HasColumnType("integer")
.HasAnnotation("Relational:JsonPropertyName", "xp");
b.HasKey("Id");
b.HasIndex("PlayerId")
.IsUnique();
b.ToTable("player_progressions", (string)null);
});
modelBuilder.Entity("CannedNet.PlayerSetting", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Key")
.IsRequired()
.HasColumnType("text")
.HasAnnotation("Relational:JsonPropertyName", "key");
b.Property<int>("PlayerId")
.HasColumnType("integer")
.HasAnnotation("Relational:JsonPropertyName", "playerId");
b.Property<string>("Value")
.IsRequired()
.HasColumnType("text")
.HasAnnotation("Relational:JsonPropertyName", "value");
b.HasKey("Id");
b.HasIndex("PlayerId", "Key")
.IsUnique();
b.ToTable("player_settings", (string)null);
});
modelBuilder.Entity("CannedNet.SavedOutfit", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("FaceFeatures")
.IsRequired()
.HasColumnType("text")
.HasAnnotation("Relational:JsonPropertyName", "FaceFeatures");
b.Property<string>("HairColor")
.IsRequired()
.HasColumnType("text")
.HasAnnotation("Relational:JsonPropertyName", "HairColor");
b.Property<string>("OutfitSelections")
.IsRequired()
.HasColumnType("text")
.HasAnnotation("Relational:JsonPropertyName", "OutfitSelections");
b.Property<int>("OwnerAccountId")
.HasColumnType("integer");
b.Property<string>("PreviewImageName")
.IsRequired()
.HasColumnType("text")
.HasAnnotation("Relational:JsonPropertyName", "PreviewImageName");
b.Property<string>("SkinColor")
.IsRequired()
.HasColumnType("text")
.HasAnnotation("Relational:JsonPropertyName", "SkinColor");
b.Property<int>("Slot")
.HasColumnType("integer")
.HasAnnotation("Relational:JsonPropertyName", "Slot");
b.HasKey("Id");
b.HasIndex("OwnerAccountId")
.IsUnique();
b.ToTable("saved_outfits", (string)null);
});
#pragma warning restore 612, 618
}
}
}
@@ -0,0 +1,47 @@
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace CannedNet.Migrations
{
/// <inheritdoc />
public partial class AddSavedOutfits : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "saved_outfits",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
OwnerAccountId = table.Column<int>(type: "integer", nullable: false),
Slot = table.Column<int>(type: "integer", nullable: false),
PreviewImageName = table.Column<string>(type: "text", nullable: false),
OutfitSelections = table.Column<string>(type: "text", nullable: false),
HairColor = table.Column<string>(type: "text", nullable: false),
SkinColor = table.Column<string>(type: "text", nullable: false),
FaceFeatures = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_saved_outfits", x => x.Id);
});
migrationBuilder.CreateIndex(
name: "IX_saved_outfits_OwnerAccountId",
table: "saved_outfits",
column: "OwnerAccountId",
unique: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "saved_outfits");
}
}
}
@@ -245,6 +245,54 @@ namespace CannedNet.Migrations
b.ToTable("player_settings", (string)null); b.ToTable("player_settings", (string)null);
}); });
modelBuilder.Entity("CannedNet.SavedOutfit", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("FaceFeatures")
.IsRequired()
.HasColumnType("text")
.HasAnnotation("Relational:JsonPropertyName", "FaceFeatures");
b.Property<string>("HairColor")
.IsRequired()
.HasColumnType("text")
.HasAnnotation("Relational:JsonPropertyName", "HairColor");
b.Property<string>("OutfitSelections")
.IsRequired()
.HasColumnType("text")
.HasAnnotation("Relational:JsonPropertyName", "OutfitSelections");
b.Property<int>("OwnerAccountId")
.HasColumnType("integer");
b.Property<string>("PreviewImageName")
.IsRequired()
.HasColumnType("text")
.HasAnnotation("Relational:JsonPropertyName", "PreviewImageName");
b.Property<string>("SkinColor")
.IsRequired()
.HasColumnType("text")
.HasAnnotation("Relational:JsonPropertyName", "SkinColor");
b.Property<int>("Slot")
.HasColumnType("integer")
.HasAnnotation("Relational:JsonPropertyName", "Slot");
b.HasKey("Id");
b.HasIndex("OwnerAccountId")
.IsUnique();
b.ToTable("saved_outfits", (string)null);
});
#pragma warning restore 612, 618 #pragma warning restore 612, 618
} }
} }
+21
View File
@@ -0,0 +1,21 @@
using System.Text.Json.Serialization;
namespace CannedNet;
public class SavedOutfit
{
public int Id { get; set; }
public int OwnerAccountId { get; set; }
[JsonPropertyName("Slot")]
public int Slot { get; set; }
[JsonPropertyName("PreviewImageName")]
public string PreviewImageName { get; set; }
[JsonPropertyName("OutfitSelections")]
public string OutfitSelections { get; set; }
[JsonPropertyName("HairColor")]
public string HairColor { get; set; }
[JsonPropertyName("SkinColor")]
public string SkinColor { get; set; }
[JsonPropertyName("FaceFeatures")]
public string FaceFeatures { get; set; }
}
+36
View File
@@ -170,6 +170,31 @@ public class APIService
await db.SaveChangesAsync(); await db.SaveChangesAsync();
return Results.Ok(avatar); return Results.Ok(avatar);
}); });
app.MapGet("/api/avatar/v3/saved", async (HttpRequest request, AppDbContext 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))
return Results.Unauthorized();
if (!int.TryParse(accountId.AsSpan(), out var id))
return Results.Unauthorized();
request.EnableBuffering();
var items = await db.SavedOutfits
.Where(i => i.OwnerAccountId == id)
.ToListAsync();
return Results.Json(items);
});
app.MapGet("/api/PlayerReporting/v1/moderationBlockDetails", () => app.MapGet("/api/PlayerReporting/v1/moderationBlockDetails", () =>
Results.Content("{\"ReportCategory\":0,\"Duration\":0,\"GameSessionId\":0,\"IsHostKick\":false,\"Message\":\"\",\"PlayerIdReporter\":null,\"IsBan\":false}", "application/json")); Results.Content("{\"ReportCategory\":0,\"Duration\":0,\"GameSessionId\":0,\"IsHostKick\":false,\"Message\":\"\",\"PlayerIdReporter\":null,\"IsBan\":false}", "application/json"));
@@ -245,5 +270,16 @@ public class APIService
await db.SaveChangesAsync(); await db.SaveChangesAsync();
return Results.Ok(); return Results.Ok();
}); });
app.MapGet("/api/equipment/v2/getUnlocked", async (HttpRequest request, AppDbContext db) =>
{
// TODO ADD FUNCTIONALITY
return "[]";
});
app.MapGet("/api/consumables/v2/getUnlocked", async (HttpRequest request, AppDbContext db) =>
{
// TODO ADD FUNCTIONALITY
return "[]";
});
} }
} }
+29
View File
@@ -31,5 +31,34 @@ public class MatchmakingService
return Results.Json(accounts); return Results.Json(accounts);
}); });
app.MapPost("/goto/room/{room}", (HttpRequest request, string room) =>
{
// dormroom location id : 76d98498-60a1-430c-ab76-b54a29b7a163
return Results.Json(new
{
errorCode = 0,
roomInstance = new
{
roomInstanceId = 1,
roomId = 1,
subRoomId = 1,
roomInstanceType = 2,
location = "76d98498-60a1-430c-ab76-b54a29b7a163",
dataBlob = "",
eventId = 0,
clubId=0,
photonRegionId = "us",
photonRoomId = "CannedNet_"+Guid.NewGuid(),
name = "DormRoom",
maxCapacity = 4,
isFull = false,
isPrivate = true,
isInProgress = false,
EncryptVoiceChat=false
}
});
});
} }
} }