diff --git a/src/admin/handlers.rs b/src/admin/handlers.rs index 6d02bd7..cb4790a 100644 --- a/src/admin/handlers.rs +++ b/src/admin/handlers.rs @@ -310,40 +310,6 @@ pub async fn verify_command( } } } - -// Config handlers -pub async fn get_config( - State(state): State>, -) -> Result>, (StatusCode, Json)> { - match db::repositories::config::get_all(&state.db).await { - Ok(config) => Ok(Json(config)), - Err(e) => { - error!("Failed to get config: {}", e); - Err(( - StatusCode::INTERNAL_SERVER_ERROR, - Json(ApiError::new("Failed to fetch configuration")), - )) - } - } -} - -pub async fn update_config( - State(state): State>, - Json(config): Json>, -) -> Result)> { - for (key, value) in config { - if let Err(e) = db::repositories::config::set(&state.db, &key, &value, None).await { - error!("Failed to update config {}: {}", key, e); - return Err(( - StatusCode::INTERNAL_SERVER_ERROR, - Json(ApiError::new(format!("Failed to update config: {}", e))), - )); - } - } - - Ok(StatusCode::OK) -} - // Log handlers pub async fn list_logs( State(state): State>, diff --git a/src/admin/routes.rs b/src/admin/routes.rs index 11fc9ba..bb4f078 100644 --- a/src/admin/routes.rs +++ b/src/admin/routes.rs @@ -22,8 +22,6 @@ pub fn admin_routes(ctx: Arc) -> Router> { .route("/api/rules/{:id}", delete(handlers::delete_rule)) .route("/api/commands", get(handlers::list_commands)) .route("/api/commands/{:id}", post(handlers::verify_command)) - .route("/api/config", get(handlers::get_config)) - .route("/api/config", put(handlers::update_config)) .route("/api/logs", get(handlers::list_logs)) .layer(axum::middleware::from_fn_with_state( ctx, diff --git a/src/db/repositories/commands.rs b/src/db/repositories/commands.rs index ca648f4..2a4191b 100644 --- a/src/db/repositories/commands.rs +++ b/src/db/repositories/commands.rs @@ -57,18 +57,6 @@ pub async fn update_status( Ok(()) } -pub async fn delete_old(pool: &SqlitePool, days: i64) -> anyhow::Result { - let result = sqlx::query( - "DELETE FROM commands WHERE status IN ('verified', 'rejected') - AND processed_at < datetime('now', '-' || ? || ' days')", - ) - .bind(days) - .execute(pool) - .await?; - - Ok(result.rows_affected()) -} - pub async fn clear_verified(pool: &SqlitePool) -> anyhow::Result<()> { sqlx::query("DELETE FROM commands WHERE status = 'verified'") .execute(pool) diff --git a/src/db/repositories/config.rs b/src/db/repositories/config.rs index bee02d7..e0f5b80 100644 --- a/src/db/repositories/config.rs +++ b/src/db/repositories/config.rs @@ -1,16 +1,6 @@ -use crate::db::models::Config; use sqlx::SqlitePool; -use std::collections::HashMap; -pub async fn get_all(pool: &SqlitePool) -> anyhow::Result> { - let configs = sqlx::query_as::<_, Config>("SELECT * FROM config") - .fetch_all(pool) - .await?; - - let map: HashMap = configs.into_iter().map(|c| (c.key, c.value)).collect(); - - Ok(map) -} +use crate::db::models::Config; pub async fn get(pool: &SqlitePool, key: &str) -> anyhow::Result> { let config = sqlx::query_as::<_, Config>("SELECT * FROM config WHERE key = ?") @@ -40,12 +30,3 @@ pub async fn set( Ok(()) } - -pub async fn delete(pool: &SqlitePool, key: &str) -> anyhow::Result<()> { - sqlx::query("DELETE FROM config WHERE key = ?") - .bind(key) - .execute(pool) - .await?; - - Ok(()) -}