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