mirror of
https://github.com/DorkSquadRR/DorkNet.git
synced 2026-10-25 23:18:44 -07:00
feat: Update room restoration logic to use consistent timestamp and response structure
This commit is contained in:
@@ -319,8 +319,9 @@ public class RoomsController(
|
|||||||
var sceneRow = sceneRows.FirstOrDefault(s => s.OrderIndex == (int)subRoomId);
|
var sceneRow = sceneRows.FirstOrDefault(s => s.OrderIndex == (int)subRoomId);
|
||||||
if (sceneRow is null) return NotFound(new { error = "subroom_not_found", subRoomId });
|
if (sceneRow is null) return NotFound(new { error = "subroom_not_found", subRoomId });
|
||||||
|
|
||||||
|
var restoredAt = DateTime.UtcNow;
|
||||||
sceneRow.DataBlobName = filename;
|
sceneRow.DataBlobName = filename;
|
||||||
sceneRow.DataModifiedAt = DateTime.UtcNow;
|
sceneRow.DataModifiedAt = restoredAt;
|
||||||
|
|
||||||
// Only stamp the room-level CurrentDataBlobName when restoring the
|
// Only stamp the room-level CurrentDataBlobName when restoring the
|
||||||
// entry scene (OrderIndex 0). Restoring a non-entry sub-room
|
// entry scene (OrderIndex 0). Restoring a non-entry sub-room
|
||||||
@@ -331,7 +332,9 @@ public class RoomsController(
|
|||||||
.Where(r => r.Id == roomId)
|
.Where(r => r.Id == roomId)
|
||||||
.ExecuteUpdateAsync(s => s
|
.ExecuteUpdateAsync(s => s
|
||||||
.SetProperty(r => r.CurrentDataBlobName, filename)
|
.SetProperty(r => r.CurrentDataBlobName, filename)
|
||||||
.SetProperty(r => r.UpdatedAt, DateTime.UtcNow));
|
.SetProperty(r => r.UpdatedAt, restoredAt));
|
||||||
|
room.CurrentDataBlobName = filename;
|
||||||
|
room.UpdatedAt = restoredAt;
|
||||||
}
|
}
|
||||||
await db.SaveChangesAsync();
|
await db.SaveChangesAsync();
|
||||||
|
|
||||||
@@ -345,13 +348,13 @@ public class RoomsController(
|
|||||||
"[rooms-restore] player={PlayerId} room={RoomId} subRoom={SubRoomId} scene={Scene} blob={Blob}",
|
"[rooms-restore] player={PlayerId} room={RoomId} subRoom={SubRoomId} scene={Scene} blob={Blob}",
|
||||||
pid, roomId, subRoomId, sceneRow.Name, filename);
|
pid, roomId, subRoomId, sceneRow.Name, filename);
|
||||||
|
|
||||||
// Watch's response deserializer is PPENFJMFPNE — the full Room DTO
|
// Watch's response deserializer is RecNetResult<PPENFJMFPNE> —
|
||||||
// (verified at EJDCNGBEICB:6029 in the 2020.12.18 dump). Returning
|
// the same legacy success/value/error envelope used by
|
||||||
// a bare RoomScene wrapper makes its dict-based decoder throw
|
// roomserver/rooms/{id}/subrooms/{id}/data. `value` must be the
|
||||||
// KeyNotFoundException ("Failed to restore subroom save: Malformed
|
// flattened /roomserver/rooms/{id} DTO, not the modern
|
||||||
// Response"). Mirror the /roomserver/rooms/{id} shape — same
|
// { Room, Scenes } details payload pushed over SubscriptionUpdateRoom.
|
||||||
// payload BuildRoomDetails generates for /v4/details.
|
var roomServerDetails = BuildRoomServerDetails(pushRoom, sceneRows, filename);
|
||||||
return Ok(roomDetailsPayload);
|
return Ok(new { success = true, value = roomServerDetails, error = string.Empty });
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>POST api/rooms/v4/saveData — the watch's
|
/// <summary>POST api/rooms/v4/saveData — the watch's
|
||||||
@@ -616,9 +619,13 @@ public class RoomsController(
|
|||||||
CanMatchmakeInto = sceneRow?.CanMatchmakeInto ?? true,
|
CanMatchmakeInto = sceneRow?.CanMatchmakeInto ?? true,
|
||||||
DataModifiedAt = savedAt.ToString("yyyy-MM-ddTHH:mm:ssZ"),
|
DataModifiedAt = savedAt.ToString("yyyy-MM-ddTHH:mm:ssZ"),
|
||||||
};
|
};
|
||||||
return Ok(wrapCreateModifyResponse
|
if (wrapCreateModifyResponse)
|
||||||
? new { success = true, value = savedScene, error = string.Empty }
|
{
|
||||||
: savedScene);
|
var roomServerDetails = BuildRoomServerDetails(pushRoom, sceneRowsForRoom, newBlob);
|
||||||
|
return Ok(new { success = true, value = roomServerDetails, error = string.Empty });
|
||||||
|
}
|
||||||
|
|
||||||
|
return Ok(savedScene);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class SaveRoomSceneRequest
|
public class SaveRoomSceneRequest
|
||||||
|
|||||||
Reference in New Issue
Block a user