(
id: i32,
store: Store,
question: Question,
)
| 31 | } |
| 32 | |
| 33 | pub async fn update_question( |
| 34 | id: i32, |
| 35 | store: Store, |
| 36 | question: Question, |
| 37 | ) -> Result<impl warp::Reply, warp::Rejection> { |
| 38 | let title = check_profanity(question.title); |
| 39 | let content = check_profanity(question.content); |
| 40 | |
| 41 | let (title, content) = tokio::join!(title, content); |
| 42 | |
| 43 | if title.is_err() { |
| 44 | return Err(warp::reject::custom(title.unwrap_err())); |
| 45 | } |
| 46 | |
| 47 | if content.is_err() { |
| 48 | return Err(warp::reject::custom(content.unwrap_err())); |
| 49 | } |
| 50 | |
| 51 | let question = Question { |
| 52 | id: question.id, |
| 53 | title: title.unwrap(), |
| 54 | content: content.unwrap(), |
| 55 | tags: question.tags, |
| 56 | }; |
| 57 | |
| 58 | match store.update_question(question, id).await { |
| 59 | Ok(res) => Ok(warp::reply::json(&res)), |
| 60 | Err(e) => Err(warp::reject::custom(e)), |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | pub async fn delete_question( |
| 65 | id: i32, |
nothing calls this directly
no test coverage detected