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