inline problem_details builder at call sites; drop the one-caller wrapper

This commit is contained in:
damocles 2026-06-22 14:31:30 +02:00 committed by mara
commit 2b0c51badf
8 changed files with 79 additions and 78 deletions

View file

@ -11,7 +11,9 @@ use axum::{
response::{IntoResponse, Response},
};
use super::{AppState, error_response, problem_response};
use problem_details::ProblemDetails;
use super::{AppState, error_response};
/// `GET /api/schedules` — snapshot of every schedule for the
/// scheduled-prompts tab. Returns the wire shape directly
@ -51,19 +53,19 @@ pub(super) async fn post_schedule_new(
axum::Json(payload): axum::Json<hive_sh4re::SchedulePromptPayload>,
) -> Response {
if payload.targets.is_empty() {
return problem_response(
StatusCode::BAD_REQUEST,
"schedule must have at least one target",
);
return ProblemDetails::from_status_code(StatusCode::BAD_REQUEST)
.with_detail("schedule must have at least one target")
.into_response();
}
if payload.body.trim().is_empty() {
return problem_response(StatusCode::BAD_REQUEST, "schedule body must be non-empty");
return ProblemDetails::from_status_code(StatusCode::BAD_REQUEST)
.with_detail("schedule body must be non-empty")
.into_response();
}
if let Some(0) = payload.interval_seconds {
return problem_response(
StatusCode::BAD_REQUEST,
"interval_seconds must be > 0 (use None for one-shot)",
);
return ProblemDetails::from_status_code(StatusCode::BAD_REQUEST)
.with_detail("interval_seconds must be > 0 (use None for one-shot)")
.into_response();
}
let new = crate::scheduled_prompts::NewSchedule {
owner: hive_sh4re::OPERATOR_RECIPIENT.to_owned(),