diff options
author | Ilion Beyst <ilion.beyst@gmail.com> | 2022-07-24 15:15:09 +0200 |
---|---|---|
committer | Ilion Beyst <ilion.beyst@gmail.com> | 2022-07-24 15:15:42 +0200 |
commit | 33664eff2c93136658b7f863c95e1bfda91141ee (patch) | |
tree | acda060d878b557e58db042a3bb30ff4212c17b1 /planetwars-server/src/routes/bots.rs | |
parent | 4a582e8079178a7ac11f2a492e7988fcdaa210cd (diff) | |
download | planetwars.dev-33664eff2c93136658b7f863c95e1bfda91141ee.tar.xz planetwars.dev-33664eff2c93136658b7f863c95e1bfda91141ee.zip |
basic user profile pages
Diffstat (limited to 'planetwars-server/src/routes/bots.rs')
-rw-r--r-- | planetwars-server/src/routes/bots.rs | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/planetwars-server/src/routes/bots.rs b/planetwars-server/src/routes/bots.rs index fc180d8..896359c 100644 --- a/planetwars-server/src/routes/bots.rs +++ b/planetwars-server/src/routes/bots.rs @@ -12,6 +12,7 @@ use std::path::PathBuf; use std::sync::Arc; use thiserror; +use crate::db; use crate::db::bots::{self, BotVersion}; use crate::db::ratings::{self, RankedBot}; use crate::db::users::User; @@ -158,11 +159,13 @@ pub async fn get_bot( }))) } -pub async fn get_my_bots( +pub async fn get_user_bots( conn: DatabaseConnection, - user: User, + Path(user_name): Path<String>, ) -> Result<Json<Vec<Bot>>, StatusCode> { - bots::find_bots_by_owner(user.id, &conn) + let user = + db::users::find_user_by_name(&user_name, &conn).map_err(|_| StatusCode::NOT_FOUND)?; + db::bots::find_bots_by_owner(user.id, &conn) .map(Json) .map_err(|_| StatusCode::INTERNAL_SERVER_ERROR) } |