diff options
| author | historia <[not public]> | 2026-09-16 17:05:17 -0400 |
|---|---|---|
| committer | historia <[not public]> | 2026-09-16 17:05:17 -0400 |
| commit | 1dad15698845d370e998f7cc5feb8aece3fab58f (patch) | |
| tree | 8d58058782de9f422573e1f8efd5d130ce7d1ce9 /internal/admin/api_rooms_bulk_delete.go | |
| parent | a6cf03a6ae98e4fb675da25046d148e92bcf7206 (diff) | |
| download | thehouseoficarus-1dad15698845d370e998f7cc5feb8aece3fab58f.tar.gz | |
refactor: remove dead code, consolidate save/error handling, add lint gate
Diffstat (limited to 'internal/admin/api_rooms_bulk_delete.go')
| -rw-r--r-- | internal/admin/api_rooms_bulk_delete.go | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/internal/admin/api_rooms_bulk_delete.go b/internal/admin/api_rooms_bulk_delete.go index 70c2eb6..5b525f6 100644 --- a/internal/admin/api_rooms_bulk_delete.go +++ b/internal/admin/api_rooms_bulk_delete.go @@ -24,18 +24,18 @@ func (s *AdminServer) handleBulkDelete(w http.ResponseWriter, r *http.Request) { body, readErr := io.ReadAll(r.Body) r.Body.Close() if readErr != nil { - writeJSON(w, map[string]any{"error": fmt.Sprintf("read body: %v", readErr)}) + failJSON(w, fmt.Sprintf("read body: %v", readErr)) return } var req bulkDeleteRequest if err := json.Unmarshal(body, &req); err != nil { - writeJSON(w, map[string]any{"error": fmt.Sprintf("invalid json: %v", err)}) + failJSON(w, fmt.Sprintf("invalid json: %v", err)) return } if len(req.IDs) == 0 { - writeJSON(w, map[string]any{"error": "no room ids"}) + failJSON(w, "no room ids") return } @@ -45,7 +45,7 @@ func (s *AdminServer) handleBulkDelete(w http.ResponseWriter, r *http.Request) { seenIDs := make(map[int]bool, len(req.IDs)) for _, id := range req.IDs { if seenIDs[id] { - writeJSON(w, map[string]any{"error": fmt.Sprintf("duplicate room id %d in request", id)}) + failJSON(w, fmt.Sprintf("duplicate room id %d in request", id)) return } seenIDs[id] = true @@ -61,12 +61,12 @@ func (s *AdminServer) handleBulkDelete(w http.ResponseWriter, r *http.Request) { for _, id := range req.IDs { path, ok := s.world.GetRoomPath(id) if !ok { - writeJSON(w, map[string]any{"error": fmt.Sprintf("room %d not found", id)}) + failJSON(w, fmt.Sprintf("room %d not found", id)) return } oldContent, snapErr := snapshotFile(path) if snapErr != nil { - writeJSON(w, map[string]any{"error": fmt.Sprintf("snapshot room %d: %v", id, snapErr)}) + failJSON(w, fmt.Sprintf("snapshot room %d: %v", id, snapErr)) return } snapshots = append(snapshots, roomSnapshot{id: id, path: path, oldContent: oldContent}) @@ -85,7 +85,7 @@ func (s *AdminServer) handleBulkDelete(w http.ResponseWriter, r *http.Request) { } } } - writeJSON(w, map[string]any{"error": fmt.Sprintf("delete room %d: %v", snap.id, err)}) + failJSON(w, fmt.Sprintf("delete room %d: %v", snap.id, err)) return } deletedSet[snap.id] = true |
