diff options
Diffstat (limited to 'internal/admin/api_rooms_bulk.go')
| -rw-r--r-- | internal/admin/api_rooms_bulk.go | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/internal/admin/api_rooms_bulk.go b/internal/admin/api_rooms_bulk.go index d10e0e3..b9cbb4a 100644 --- a/internal/admin/api_rooms_bulk.go +++ b/internal/admin/api_rooms_bulk.go @@ -108,7 +108,12 @@ func (s *AdminServer) handleBulkEdit(w http.ResponseWriter, r *http.Request) { newPath := path if patch.Dir != nil && *patch.Dir != "" { - destDir := filepath.Join(s.dataDir, "rooms", *patch.Dir) + dir, dirErr := s.resolveRoomSubdir(*patch.Dir) + if dirErr != nil { + failJSON(w, dirErr.Error()) + return + } + destDir := filepath.Join(s.dataDir, "rooms", dir) if _, statErr := os.Stat(destDir); os.IsNotExist(statErr) { failJSON(w, fmt.Sprintf("directory does not exist: %s", *patch.Dir)) return @@ -130,6 +135,10 @@ func (s *AdminServer) handleBulkEdit(w http.ResponseWriter, r *http.Request) { failJSON(w, fmt.Sprintf("marshal room %d: %v", id, marshalErr)) return } + if err := validateRoomSchema(newContent); err != nil { + failJSON(w, fmt.Sprintf("room %d failed schema validation: %v", id, err)) + return + } writes = append(writes, roomWrite{id: id, oldPath: path, newPath: newPath, oldContent: oldContent, newContent: newContent}) } |
