Allow forced server deletion

This commit is contained in:
npc0-hue
2026-08-04 15:03:49 +08:00
parent 96a1939f32
commit cf9af14eaf
17 changed files with 236 additions and 24 deletions
+3 -3
View File
@@ -1305,12 +1305,12 @@ func (h *coreHandlers) serverInstances(w http.ResponseWriter, r *http.Request) {
// serverInstanceDetail godoc
// @Summary Get, update, or delete server instance
// @Description Returns one server instance by ID, updates safe metadata, or deletes it by marking the instance deleted after safety validation and password confirmation. Delete requests send a JSON body with the current password.
// @Description Returns one server instance by ID, updates safe metadata, or deletes it by marking the instance deleted after safety validation and password confirmation. Delete requests send a JSON body with the current password and may include explicit forced-delete confirmation for running or installing instances.
// @Tags server-instances
// @Accept json
// @Produce json
// @Param id path string true "Server instance ID"
// @Param body body dto.ServerInstanceUpdateRequest false "Server metadata update request"
// @Param body body dto.ServerDeletionRequest false "Server metadata update or deletion request"
// @Success 204
// @Success 200 {object} dto.ServerInstanceResponse
// @Failure 400 {object} dto.ErrorResponse
@@ -1347,7 +1347,7 @@ func (h *coreHandlers) serverInstanceDetail(w http.ResponseWriter, r *http.Reque
writeDecodeError(w, err)
return
}
_, err = h.core.DeleteServerInstanceForSession(bearerToken(r), r.PathValue("id"), request.Password)
_, err = h.core.DeleteServerInstanceForSession(bearerToken(r), r.PathValue("id"), request.ToDomain())
if err != nil {
writeServiceError(w, err)
return