feat: Enhance room save flow with new metadata handling and add tests for 2023 client integration

This commit is contained in:
Alexa
2026-07-08 01:19:19 +03:00
parent a18236d064
commit 1417651c77
3 changed files with 170 additions and 10 deletions
@@ -1093,8 +1093,26 @@ public class RoomsController(
public long RequestPlayerId { get; set; }
public int SaveRequestPlayerId { get; set; }
// 2023 client shape. rooms/{id}/subrooms/{id}/data arrives as JSON:
// { "UnityAssetId": null,
// "RoomData": { "Filename": "roommeta_….bin", "Hash": …, "OwnershipProof": … },
// "SubRoomData": { "Filename": "dorm_p…_vN.dat", "Hash": …, "OwnershipProof": … } }
// SubRoomData.Filename is the scene save blob (the FileType=1
// /upload result) — that's what must become DataBlobName.
// RoomData.Filename is the FileType=6 room-metadata blob.
public long? UnityAssetId { get; set; }
public BlobRefDto? RoomData { get; set; }
public BlobRefDto? SubRoomData { get; set; }
public string EffectiveRoomDataFilename =>
RoomDataFilename ?? Filename ?? string.Empty;
RoomDataFilename ?? Filename ?? SubRoomData?.Filename ?? string.Empty;
}
public class BlobRefDto
{
public string? Filename { get; set; }
public string? Hash { get; set; }
public string? OwnershipProof { get; set; }
}
public class CreatorActionContextDto
@@ -3411,9 +3429,14 @@ public class RoomsController(
/// commit the blob returned by <c>storage/upload</c> as the current
/// scene save. The 2020 watch posts this as form-urlencoded
/// (<c>filename</c>, <c>inventionUsage</c>, <c>savedByAccountId</c>),
/// while some tooling uses JSON. Both variants delegate to the
/// existing saveData path so room, scene, dorm-state, presence, and
/// subscription fanout stay consistent.</summary>
/// while some tooling uses JSON. The 2023 client posts JSON with
/// nested blob refs — <c>{UnityAssetId, RoomData:{Filename,Hash,
/// OwnershipProof}, SubRoomData:{Filename,…}}</c> — where
/// <c>SubRoomData.Filename</c> is the scene save (FileType=1 upload)
/// and <c>RoomData.Filename</c> the FileType=6 room-metadata blob.
/// All variants delegate to the existing saveData path so room,
/// scene, dorm-state, presence, and subscription fanout stay
/// consistent.</summary>
[HttpPost("roomserver/rooms/{roomId:long}/subrooms/{subRoomId:long}/data")]
[HttpPost("rooms/{roomId:long}/subrooms/{subRoomId:long}/data")]
[Authorize]
@@ -44,15 +44,23 @@ public class StorageController(
/// FileType enum values from the client's <c>RecNet.Storage+FileType</c>
/// (dump.cs:586846). Kept as a private enum so callers can pattern-
/// match without leaking client-side numbering elsewhere.
///
/// <c>RoomMetadata = 6</c> is new in the 2023 client: the room-save
/// flow (<c>OGPDOMCNIFM.UploadRoomDataBlobAndSyncReload</c>, logs
/// "Uploading room metadata {0}/{1}") uploads a small metadata blob
/// with FileType=6 alongside the FileType=1 scene save, then posts
/// both returned filenames to <c>rooms/{id}/subrooms/{id}/data</c>
/// as <c>{RoomData:{Filename},SubRoomData:{Filename}}</c>.
/// </summary>
private enum FileType
{
Unknown = 0,
RoomSave = 1,
Holotar = 2,
Image = 3,
Video = 4,
Invention = 5,
Unknown = 0,
RoomSave = 1,
Holotar = 2,
Image = 3,
Video = 4,
Invention = 5,
RoomMetadata = 6,
}
[HttpPost("/upload", Order = -2000)]
@@ -103,6 +111,7 @@ public class StorageController(
FileType.Image => await UploadImageAsync(playerId, bytes),
FileType.Holotar => await UploadGenericAsync(playerId, bytes, "holotar"),
FileType.Video => await UploadGenericAsync(playerId, bytes, "video"),
FileType.RoomMetadata => await UploadGenericAsync(playerId, bytes, "roommeta"),
_ => Ok(new
{
filename = $"stub_{Guid.NewGuid():N}.{Extension(fileType)}",