aboutsummaryrefslogtreecommitdiff
path: root/planetwars-server
diff options
context:
space:
mode:
authorIlion Beyst <ilion.beyst@gmail.com>2022-03-01 20:23:31 +0100
committerIlion Beyst <ilion.beyst@gmail.com>2022-03-01 20:23:31 +0100
commit0f7c3c3102aff07a85fd4dfc45a1e3f8489851e7 (patch)
tree9556627413ccaecaa9fbb7a4b270a178272577ce /planetwars-server
parent5265e19507aba9948bafc984e4ccd796539c4c2f (diff)
downloadplanetwars.dev-0f7c3c3102aff07a85fd4dfc45a1e3f8489851e7.tar.xz
planetwars.dev-0f7c3c3102aff07a85fd4dfc45a1e3f8489851e7.zip
don't allow overwriting bots for now
Diffstat (limited to 'planetwars-server')
-rw-r--r--planetwars-server/src/routes/bots.rs6
1 files changed, 3 insertions, 3 deletions
diff --git a/planetwars-server/src/routes/bots.rs b/planetwars-server/src/routes/bots.rs
index 66479bb..6a5612a 100644
--- a/planetwars-server/src/routes/bots.rs
+++ b/planetwars-server/src/routes/bots.rs
@@ -23,13 +23,13 @@ pub struct SaveBotParams {
pub async fn save_bot(
Json(params): Json<SaveBotParams>,
conn: DatabaseConnection,
-) -> Result<(), StatusCode> {
+) -> Result<Json<Bot>, StatusCode> {
// TODO: authorization
let res = bots::find_bot_by_name(&params.bot_name, &conn)
.optional()
.expect("could not run query");
let bot = match res {
- Some(bot) => bot,
+ Some(_bot) => return Err(StatusCode::FORBIDDEN),
None => {
let new_bot = bots::NewBot {
owner_id: None,
@@ -41,7 +41,7 @@ pub async fn save_bot(
};
let _code_bundle =
save_code_bundle(&params.code, Some(bot.id), &conn).expect("failed to save code bundle");
- Ok(())
+ Ok(Json(bot))
}
#[derive(Serialize, Deserialize, Debug)]