aboutsummaryrefslogtreecommitdiff
path: root/internal/admin/api_rooms.go
diff options
context:
space:
mode:
authorhistoria <[not public]>2026-06-30 19:27:37 -0400
committerhistoria <[not public]>2026-06-30 19:27:37 -0400
commitfee376102192dc6f24297a7b11324636ace3a07d (patch)
tree6c777cc71208b429eebdbdc5864b353d4af34a09 /internal/admin/api_rooms.go
parent98bdef072c843fdd8ccdf85a9b54ab9d32d34187 (diff)
downloadthehouseoficarus-fee376102192dc6f24297a7b11324636ace3a07d.tar.gz
feat: admin gui object CRUD is much nicer
Diffstat (limited to 'internal/admin/api_rooms.go')
-rw-r--r--internal/admin/api_rooms.go16
1 files changed, 15 insertions, 1 deletions
diff --git a/internal/admin/api_rooms.go b/internal/admin/api_rooms.go
index a477cc3..f615d9d 100644
--- a/internal/admin/api_rooms.go
+++ b/internal/admin/api_rooms.go
@@ -4,6 +4,7 @@ import (
"encoding/json"
"fmt"
"io"
+ "log"
"net/http"
"os"
"path/filepath"
@@ -229,6 +230,7 @@ func (s *AdminServer) handleRoomByID(w http.ResponseWriter, r *http.Request) {
s.world.ClearRoomState(id)
allIDs, _ := listRoomIDs(s.dataDir)
+ var extraFiles []ExtraFile
var exitCleaned int
for _, otherID := range allIDs {
if otherID == id {
@@ -250,7 +252,16 @@ func (s *AdminServer) handleRoomByID(w http.ResponseWriter, r *http.Request) {
if changed {
otherPath, pathOk := s.world.GetRoomPath(otherID)
if pathOk {
- writeYAMLFile(otherPath, otherRoom)
+ oldExtra, _ := snapshotFile(otherPath)
+ newContent, writeErr := writeYAMLFile(otherPath, otherRoom)
+ if writeErr != nil {
+ continue
+ }
+ extraFiles = append(extraFiles, ExtraFile{
+ FilePath: otherPath,
+ OldContent: oldExtra,
+ NewContent: newContent,
+ })
exitCleaned++
}
}
@@ -261,6 +272,7 @@ func (s *AdminServer) handleRoomByID(w http.ResponseWriter, r *http.Request) {
FilePath: path,
OldContent: oldContent,
IsDelete: true,
+ ExtraFiles: extraFiles,
})
writeJSON(w, map[string]any{"ok": true})
@@ -352,6 +364,7 @@ func (s *AdminServer) handleRoomLink(w http.ResponseWriter, r *http.Request) {
grid := world.BuildGrid(s.cfg.StartingRoom, func(id int) (*world.Room, bool) {
room, err := s.world.LoadRoom(id)
if err != nil {
+ log.Printf("link: BuildGrid failed to load room %d: %v", id, err)
return nil, false
}
return room, true
@@ -402,6 +415,7 @@ func (s *AdminServer) handleRoomLink(w http.ResponseWriter, r *http.Request) {
testGrid := world.BuildGrid(s.cfg.StartingRoom, func(id int) (*world.Room, bool) {
room, err := s.world.LoadRoom(id)
if err != nil {
+ log.Printf("link: conflict test BuildGrid failed to load room %d: %v", id, err)
return nil, false
}
roomCopy := *room