diff options
| author | WriterV2 <primary-v2@protonmail.com> | 2024-11-07 17:06:03 +0100 |
|---|---|---|
| committer | WriterV2 <primary-v2@protonmail.com> | 2024-11-07 17:06:31 +0100 |
| commit | 99fc959383d5b7b26d8e80f6257adf8b98989f41 (patch) | |
| tree | a12795706e7a0dee188ea0339656807aeda5243a /src/handlers | |
| parent | 696af52b9b3a732b369a771e1f6409d8e2049ea9 (diff) | |
Feat: Add ability to add tags to story (and product in general)
Diffstat (limited to 'src/handlers')
| -rw-r--r-- | src/handlers/admin.rs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/handlers/admin.rs b/src/handlers/admin.rs index a48be21..7c016dd 100644 --- a/src/handlers/admin.rs +++ b/src/handlers/admin.rs @@ -112,6 +112,13 @@ pub async fn upload_story( return Ok(StatusCode::BAD_REQUEST.into_response()); }; + let mut tags: Vec<String> = Vec::new(); + if let Some(tags_value) = form.get("tag") { + for tag in String::from_utf8(tags_value.to_vec())?.split(",") { + tags.push(tag.trim().to_string()); + } + } + let story_template = Story { id: 0, pid: 0, @@ -120,6 +127,8 @@ pub async fn upload_story( epub, }; - let story = story_template.post(&ctx.pool, name, description).await?; + let story = story_template + .post(&ctx.pool, name, description, tags) + .await?; Ok((StatusCode::CREATED, Json(story)).into_response()) } |
