mirror of
https://github.com/storytold/artcraft.git
synced 2026-10-26 19:19:38 +00:00
refactor
This commit is contained in:
+2
-2
@@ -1,7 +1,7 @@
|
||||
use std::fmt;
|
||||
use std::sync::Arc;
|
||||
|
||||
use crate::http_server::endpoints::webhooks::process_success::process_success_case::process_fal_webhook;
|
||||
use crate::http_server::endpoints::webhooks::process_success::handle_successful_fal_webhook::handle_sucessful_fal_webhook;
|
||||
use crate::state::server_state::ServerState;
|
||||
use actix_web::error::ResponseError;
|
||||
use actix_web::http::StatusCode;
|
||||
@@ -126,7 +126,7 @@ pub async fn fal_webhook_handler(
|
||||
FalWebhookError::BadInput("Missing payload".to_string())
|
||||
})?;
|
||||
|
||||
let result = process_fal_webhook(&server_state, request_id, payload).await;
|
||||
let result = handle_sucessful_fal_webhook(&server_state, request_id, payload).await;
|
||||
|
||||
if let Err(ref err) = result {
|
||||
error!("FAL webhook error for request_id {}: {:?}", request_id, err);
|
||||
|
||||
+11
-11
@@ -8,13 +8,13 @@ use serde_json::Value;
|
||||
use crate::http_server::endpoints::webhooks::fal_webhook_handler::FalWebhookError;
|
||||
use crate::state::server_state::ServerState;
|
||||
|
||||
use super::handle_image_payload::handle_image_payload;
|
||||
use super::handle_images_payload::handle_images_payload;
|
||||
use super::handle_model_glb_payload::handle_model_glb_payload;
|
||||
use super::handle_model_mesh_payload::handle_model_mesh_payload;
|
||||
use super::handle_video_payload::handle_video_payload;
|
||||
use super::process_image_payload::process_image_payload;
|
||||
use super::process_images_payload::process_images_payload;
|
||||
use super::process_model_glb_payload::process_model_glb_payload;
|
||||
use super::process_model_mesh_payload::process_model_mesh_payload;
|
||||
use super::process_video_payload::process_video_payload;
|
||||
|
||||
pub async fn process_fal_webhook(
|
||||
pub async fn handle_sucessful_fal_webhook(
|
||||
server_state: &ServerState,
|
||||
request_id: &str,
|
||||
payload: &Value,
|
||||
@@ -45,21 +45,21 @@ pub async fn process_fal_webhook(
|
||||
if let Some(payload_obj) = payload.as_object() {
|
||||
if payload_obj.contains_key("image") {
|
||||
info!("Handling image payload for request_id {} / job {:?}", request_id, job.job_token);
|
||||
let token = handle_image_payload(payload_obj, &job, server_state).await?;
|
||||
let token = process_image_payload(payload_obj, &job, server_state).await?;
|
||||
maybe_media_token = Some(token);
|
||||
} else if payload_obj.contains_key("images") {
|
||||
(maybe_media_token, maybe_batch_token) = handle_images_payload(payload_obj, &job, server_state).await?;
|
||||
(maybe_media_token, maybe_batch_token) = process_images_payload(payload_obj, &job, server_state).await?;
|
||||
} else if payload_obj.contains_key("video") {
|
||||
info!("Handling video payload for request_id {} / job {:?}", request_id, job.job_token);
|
||||
let token = handle_video_payload(payload_obj, &job, server_state).await?;
|
||||
let token = process_video_payload(payload_obj, &job, server_state).await?;
|
||||
maybe_media_token = Some(token);
|
||||
} else if payload_obj.contains_key("model_glb") {
|
||||
info!("Handling model_glb payload for request_id {} / job {:?}", request_id, job.job_token);
|
||||
let token = handle_model_glb_payload(payload_obj, &job, server_state).await?;
|
||||
let token = process_model_glb_payload(payload_obj, &job, server_state).await?;
|
||||
maybe_media_token = Some(token);
|
||||
} else if payload_obj.contains_key("model_mesh") {
|
||||
info!("Handling model_mesh payload for request_id {} / job {:?}", request_id, job.job_token);
|
||||
let token = handle_model_mesh_payload(payload_obj, &job, server_state).await?;
|
||||
let token = process_model_mesh_payload(payload_obj, &job, server_state).await?;
|
||||
maybe_media_token = Some(token);
|
||||
}
|
||||
}
|
||||
+6
-6
@@ -1,6 +1,6 @@
|
||||
pub mod process_success_case;
|
||||
mod handle_image_payload;
|
||||
mod handle_images_payload;
|
||||
mod handle_model_glb_payload;
|
||||
mod handle_model_mesh_payload;
|
||||
mod handle_video_payload;
|
||||
pub mod handle_successful_fal_webhook;
|
||||
mod process_image_payload;
|
||||
mod process_images_payload;
|
||||
mod process_model_glb_payload;
|
||||
mod process_model_mesh_payload;
|
||||
mod process_video_payload;
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@ pub struct FalWebhookImage {
|
||||
pub url: Option<String>,
|
||||
}
|
||||
|
||||
pub async fn handle_image_payload(
|
||||
pub async fn process_image_payload(
|
||||
payload: &Map<String, Value>,
|
||||
job: &FalJobDetails,
|
||||
server_state: &ServerState,
|
||||
+1
-1
@@ -30,7 +30,7 @@ pub struct FalWebhookImage {
|
||||
pub url: Option<String>,
|
||||
}
|
||||
|
||||
pub async fn handle_images_payload(
|
||||
pub async fn process_images_payload(
|
||||
payload: &Map<String, Value>,
|
||||
job: &FalJobDetails,
|
||||
server_state: &ServerState,
|
||||
+1
-1
@@ -63,7 +63,7 @@ pub struct FalMediaPayload {
|
||||
pub url: Option<String>,
|
||||
}
|
||||
|
||||
pub async fn handle_model_glb_payload(
|
||||
pub async fn process_model_glb_payload(
|
||||
payload: &Map<String, Value>,
|
||||
job: &FalJobDetails,
|
||||
server_state: &ServerState,
|
||||
+1
-1
@@ -25,7 +25,7 @@ pub struct FalWebhookModelMesh {
|
||||
pub url: Option<String>,
|
||||
}
|
||||
|
||||
pub async fn handle_model_mesh_payload(
|
||||
pub async fn process_model_mesh_payload(
|
||||
payload: &Map<String, Value>,
|
||||
job: &FalJobDetails,
|
||||
server_state: &ServerState,
|
||||
+1
-1
@@ -31,7 +31,7 @@ pub struct FalWebhookVideo {
|
||||
pub url: Option<String>,
|
||||
}
|
||||
|
||||
pub async fn handle_video_payload(
|
||||
pub async fn process_video_payload(
|
||||
payload: &Map<String, Value>,
|
||||
job: &FalJobDetails,
|
||||
server_state: &ServerState,
|
||||
Reference in New Issue
Block a user