refactoring: new structure and mailer

This commit is contained in:
Per Stark
2024-12-19 23:15:12 +01:00
parent e54533d005
commit 13608bc41e
25 changed files with 659 additions and 379 deletions

View File

@@ -0,0 +1,28 @@
use crate::{
error::ApiError,
ingress::types::ingress_input::{create_ingress_objects, IngressInput},
server::AppState,
storage::types::user::User,
};
use axum::{extract::State, http::StatusCode, response::IntoResponse, Extension, Json};
use futures::future::try_join_all;
use tracing::info;
pub async fn ingress_handler(
State(state): State<AppState>,
Extension(user): Extension<User>,
Json(input): Json<IngressInput>,
) -> Result<impl IntoResponse, ApiError> {
info!("Received input: {:?}", input);
let ingress_objects = create_ingress_objects(input, &state.surreal_db_client, &user.id).await?;
let futures: Vec<_> = ingress_objects
.into_iter()
.map(|object| state.rabbitmq_producer.publish(object))
.collect();
try_join_all(futures).await?;
Ok(StatusCode::OK)
}