This commit is contained in:
JMARyA 2024-09-25 22:59:00 +02:00
parent e3128d7214
commit 9468629302
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263
2 changed files with 26 additions and 18 deletions

View file

@ -156,6 +156,10 @@ pub async fn end_flow_route(id: &str, form: Json<EndFlow>) -> FallibleApiRespons
.await .await
.ok_or_else(|| api_error("Flow not found"))?; .ok_or_else(|| api_error("Flow not found"))?;
if flow.done.is_some() {
return Err(api_error("Flow already ended"));
}
if let Some(produced) = &form.produced { if let Some(produced) = &form.produced {
let prod = flow.end_with_produce(produced).await?; let prod = flow.end_with_produce(produced).await?;
Ok(json!({"produced": prod})) Ok(json!({"produced": prod}))
@ -175,6 +179,10 @@ pub async fn continue_flow_route(
.await .await
.ok_or_else(|| api_error("Flow not found"))?; .ok_or_else(|| api_error("Flow not found"))?;
if this_flow.done.is_some() {
return Err(api_error("Flow already ended"));
}
// create next flow // create next flow
let next_kind = flows let next_kind = flows
.get(this_flow.kind.id()) .get(this_flow.kind.id())