mirror of
https://github.com/perstarkse/minne.git
synced 2026-04-26 18:58:29 +02:00
refactoring: new structure and mailer
This commit is contained in:
28
src/server/routes/api/ingress.rs
Normal file
28
src/server/routes/api/ingress.rs
Normal 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)
|
||||
}
|
||||
Reference in New Issue
Block a user