(
session: Session,
store: Store,
new_question: NewQuestion,
)
| 85 | } |
| 86 | |
| 87 | pub async fn add_question( |
| 88 | session: Session, |
| 89 | store: Store, |
| 90 | new_question: NewQuestion, |
| 91 | ) -> Result<impl warp::Reply, warp::Rejection> { |
| 92 | let account_id = session.account_id; |
| 93 | let title = match check_profanity(new_question.title).await { |
| 94 | Ok(res) => res, |
| 95 | Err(e) => return Err(warp::reject::custom(e)), |
| 96 | }; |
| 97 | |
| 98 | let content = match check_profanity(new_question.content).await { |
| 99 | Ok(res) => res, |
| 100 | Err(e) => return Err(warp::reject::custom(e)), |
| 101 | }; |
| 102 | |
| 103 | let question = NewQuestion { |
| 104 | title, |
| 105 | content, |
| 106 | tags: new_question.tags, |
| 107 | }; |
| 108 | |
| 109 | match store.add_question(question, account_id).await { |
| 110 | Ok(question) => Ok(warp::reply::json(&question)), |
| 111 | Err(e) => Err(warp::reject::custom(e)), |
| 112 | } |
| 113 | } |
nothing calls this directly
no test coverage detected