diff --git a/crates/api_clients/artcraft/artcraft_api_defs/src/prompts/get_prompt.rs b/crates/api_clients/artcraft/artcraft_api_defs/src/prompts/get_prompt.rs index 8eedbce967..77369ec369 100644 --- a/crates/api_clients/artcraft/artcraft_api_defs/src/prompts/get_prompt.rs +++ b/crates/api_clients/artcraft/artcraft_api_defs/src/prompts/get_prompt.rs @@ -27,13 +27,6 @@ pub struct GetPromptSuccessResponse { pub prompt: PromptInfo, } -#[derive(Serialize, ToSchema)] -pub struct GetPromptImageContextItem { - pub media_token: MediaFileToken, - pub semantic: PromptContextSemanticType, - pub media_links: MediaLinks, -} - #[derive(Serialize, ToSchema)] pub struct PromptInfo { pub token: PromptToken, @@ -130,6 +123,13 @@ pub struct PromptInfo { pub created_at: DateTime, } +#[derive(Serialize, ToSchema)] +pub struct GetPromptImageContextItem { + pub media_token: MediaFileToken, + pub semantic: PromptContextSemanticType, + pub media_links: MediaLinks, +} + #[derive(Serialize, ToSchema)] pub struct PromptInfoModeratorFields { /// How many milliseconds it took to run generation. diff --git a/crates/service/web/storyteller_web/src/http_server/endpoints/prompts/get_prompt_handler.rs b/crates/service/web/storyteller_web/src/http_server/endpoints/prompts/get_prompt_handler.rs index 7ab383cbfa..0eb7aafe8c 100644 --- a/crates/service/web/storyteller_web/src/http_server/endpoints/prompts/get_prompt_handler.rs +++ b/crates/service/web/storyteller_web/src/http_server/endpoints/prompts/get_prompt_handler.rs @@ -7,7 +7,7 @@ use crate::http_server::web_utils::response_error_helpers::to_simple_json_error; use crate::state::server_state::ServerState; use actix_web::error::ResponseError; use actix_web::http::StatusCode; -use actix_web::web::Path; +use actix_web::web::{Json, Path}; use actix_web::{web, HttpMessage, HttpRequest, HttpResponse}; use artcraft_api_defs::prompts::get_prompt::{ GetPromptImageContextItem, GetPromptPathInfo, GetPromptSuccessResponse, @@ -68,7 +68,7 @@ impl fmt::Display for GetPromptError { pub async fn get_prompt_handler( http_request: HttpRequest, path: Path, - server_state: web::Data>) -> Result + server_state: web::Data>) -> Result, GetPromptError> { let mut mysql_connection = server_state.mysql_pool .acquire() @@ -208,7 +208,7 @@ pub async fn get_prompt_handler( Some(items) }; - let response = GetPromptSuccessResponse { + Ok(Json(GetPromptSuccessResponse { success: true, prompt: PromptInfo { token: result.token, @@ -239,12 +239,5 @@ pub async fn get_prompt_handler( maybe_global_ipa_image_token, maybe_frame_skip, }, - }; - - let body = serde_json::to_string(&response) - .map_err(|e| GetPromptError::ServerError)?; - - Ok(HttpResponse::Ok() - .content_type("application/json") - .body(body)) + })) }