From 0ab5fee8b2152066d01e3ceabc03e43db62fba6b Mon Sep 17 00:00:00 2001 From: Reimar Date: Fri, 13 Sep 2024 12:06:45 +0200 Subject: [PATCH] Show image immediately after submitting review --- rust-backend/src/main.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/rust-backend/src/main.rs b/rust-backend/src/main.rs index 004ddbe..ba3e442 100644 --- a/rust-backend/src/main.rs +++ b/rust-backend/src/main.rs @@ -217,9 +217,11 @@ async fn create_review(auth: AuthorizedUser, data: web::Data, input: we place_description: input.place_description.clone(), title: input.title.clone(), content: input.content.clone(), - rating: input.rating.clone(), + rating: input.rating.clone(), image_id: input.image_id, - image: None, + image: input.image_id.and_then(|image_id| { + db.query_row("SELECT * FROM images WHERE id = :id LIMIT 1", &[(":id", &image_id.to_string())], |row| Image::from_row(row)).ok() + }), }), Err(_) => HttpResponse::InternalServerError().finish(), }