(
store: Store,
new_answer: NewAnswer,
)
| 5 | use crate::types::answer::NewAnswer; |
| 6 | |
| 7 | pub async fn add_answer( |
| 8 | store: Store, |
| 9 | new_answer: NewAnswer, |
| 10 | ) -> Result<impl warp::Reply, warp::Rejection> { |
| 11 | let content = match |
| 12 | check_profanity(new_answer.content).await { |
| 13 | Ok(res) => res, |
| 14 | Err(e) => return Err(warp::reject::custom(e)), |
| 15 | }; |
| 16 | |
| 17 | let answer = NewAnswer { |
| 18 | content, |
| 19 | question_id: new_answer.question_id, |
| 20 | }; |
| 21 | |
| 22 | match store.add_answer(answer).await { |
| 23 | Ok(_) => { |
| 24 | Ok(warp::reply::with_status("Answer added", StatusCode::OK)) |
| 25 | } |
| 26 | Err(e) => Err(warp::reject::custom(e)), |
| 27 | } |
| 28 | } |
nothing calls this directly
no test coverage detected