diff --git a/src/routes.rs b/src/routes.rs index ed6ffea..e9fdf01 100644 --- a/src/routes.rs +++ b/src/routes.rs @@ -9,7 +9,9 @@ use std::sync::Arc; use tokio::task; use tracing::info; -use crate::{db, errors, extractors::ValidatedJson, mailer, states, templates, webhook}; +use crate::{ + db, errors::AppError, extractors::ValidatedJson, mailer::Mailer, states, templates, webhook, +}; #[derive(Deserialize)] pub struct IndexQuery { @@ -19,7 +21,7 @@ pub struct IndexQuery { pub async fn index( State(db): State>, query: Query, -) -> Result { +) -> Result { let id = match query.id { Some(id) if id != 0 => id, Some(_) => return Err("id=0 not allowed!".into()), @@ -38,9 +40,9 @@ pub async fn index( pub async fn trigger( State(db): State>, State(state_config): State>, - State(mailer): State>, + State(mailer): State>, ValidatedJson(json): ValidatedJson, -) -> Result { +) -> Result { info!("Trigger called"); let repo = json diff --git a/src/states.rs b/src/states.rs index b3230a8..92d0abd 100644 --- a/src/states.rs +++ b/src/states.rs @@ -2,7 +2,7 @@ use anyhow::Result; use axum::extract::FromRef; use std::sync::Arc; -use crate::{config, db, mailer}; +use crate::{config, db, mailer::Mailer}; pub struct DB { pub pool: db::DBPool, @@ -41,12 +41,12 @@ impl StateConfig { #[derive(Clone, FromRef)] pub struct AppState { pub config: Arc, - pub mailer: Arc, + pub mailer: Arc, pub db: Arc, } impl AppState { - pub fn build(config: config::Config, mailer: mailer::Mailer) -> Result { + pub fn build(config: config::Config, mailer: Mailer) -> Result { Ok(Self { config: Arc::new(StateConfig::from(config)), mailer: Arc::new(mailer), diff --git a/src/webhook.rs b/src/webhook.rs index da93bba..df41314 100644 --- a/src/webhook.rs +++ b/src/webhook.rs @@ -1,14 +1,14 @@ use std::{process::Command, sync::Arc}; use tracing::{error, info}; -use crate::{config, db, mailer, states}; +use crate::{config, db, mailer::Mailer, states}; pub struct TaskContext { pub hook: config::Hook, pub hook_log_id: i32, pub hook_log_link: String, pub db: Arc, - pub mailer: Arc, + pub mailer: Arc, } pub async fn run(context: TaskContext) {