diff options
Diffstat (limited to 'crates/rocie-server/src/api/set/auth/recipe.rs')
| -rw-r--r-- | crates/rocie-server/src/api/set/auth/recipe.rs | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/crates/rocie-server/src/api/set/auth/recipe.rs b/crates/rocie-server/src/api/set/auth/recipe.rs index 43a034e..b9f930d 100644 --- a/crates/rocie-server/src/api/set/auth/recipe.rs +++ b/crates/rocie-server/src/api/set/auth/recipe.rs @@ -1,5 +1,3 @@ -use std::path::PathBuf; - use actix_identity::Identity; use actix_web::{HttpResponse, Responder, error::Result, post, web}; use serde::Deserialize; @@ -10,14 +8,18 @@ use crate::{ storage::sql::{ insert::Operations, recipe::{Recipe, RecipeId}, + recipe_parent::RecipeParentId, }, }; #[derive(Deserialize, ToSchema)] struct RecipeStub { - /// The path the recipe should have - #[schema(value_type = String)] - path: PathBuf, + /// The globally unique name of this recipe + name: String, + + /// The optional parent of this recipe. + #[schema(nullable = false)] + parent: Option<RecipeParentId>, /// The content of this recipe, in cooklang format content: String, @@ -52,7 +54,14 @@ pub(crate) async fn add_recipe( let stub = stub.into_inner(); let mut ops = Operations::new("add recipe parent"); - let recipe = Recipe::new(stub.path, stub.content, &mut ops); + let recipe = Recipe::new( + &app, + stub.name, + stub.parent, + stub.content, + &mut ops, + ) + .await?; ops.apply(&app).await?; |
