(
id: i32,
session: Session,
store: Store,
)
| 66 | } |
| 67 | |
| 68 | pub async fn delete_question( |
| 69 | id: i32, |
| 70 | session: Session, |
| 71 | store: Store, |
| 72 | ) -> Result<impl warp::Reply, warp::Rejection> { |
| 73 | let account_id = session.account_id; |
| 74 | if store.is_question_owner(id, &account_id).await? { |
| 75 | match store.delete_question(id, account_id).await { |
| 76 | Ok(_) => Ok(warp::reply::with_status( |
| 77 | format!("Question {} deleted", id), |
| 78 | StatusCode::OK, |
| 79 | )), |
| 80 | Err(e) => Err(warp::reject::custom(e)), |
| 81 | } |
| 82 | } else { |
| 83 | Err(warp::reject::custom(handle_errors::Error::Unauthorized)) |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | pub async fn add_question( |
| 88 | session: Session, |
nothing calls this directly
no test coverage detected