From 0d5f5f4b227cf96f21a0a4048fa582be46f1742f Mon Sep 17 00:00:00 2001 From: Accusys Date: Mon, 5 Oct 2026 02:34:50 +0800 Subject: [PATCH] fix: resolve api-key function signature mismatch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit **問題**: - main.rs 有舊的 handle_api_key stub - 函數簽名不匹配 **修復**: 1. 刪除 main.rs:337-352 舊函數 2. 修改 main.rs:122 調用: - action 傳引用 (&action) - ttl 類型轉換 (ttl.map(|i| i as u64)) - 添加 key_id 參數 (None) **驗證**: - ✅ 編譯成功 - ✅ 字串檢查通過 - ✅ 類型匹配正確 --- src/main.rs | 18 +----------------- src/processing/handlers.rs | 4 ++-- 2 files changed, 3 insertions(+), 19 deletions(-) diff --git a/src/main.rs b/src/main.rs index fee513c9..54178b66 100644 --- a/src/main.rs +++ b/src/main.rs @@ -119,7 +119,7 @@ async fn main() -> Result<()> { ttl, key, } => { - handle_api_key(action, name, key_type, ttl, key).await?; + handle_api_key(&action, name, key_type, ttl.map(|i| i as u64), key, None).await?; } Commands::Gitea { action, @@ -333,23 +333,7 @@ async fn handle_backup(action: &str, days: Option) -> Result<()> { Ok(()) } -/// Handle API key command -async fn handle_api_key( - action: ApiKeyAction, - name: Option, - key_type: Option, - ttl: Option, - key: Option, -) -> Result<()> { - println!("API Key action: {:?}", action); - println!("Name: {:?}", name); - println!("Key type: {:?}", key_type); - println!("TTL: {:?}", ttl); - println!("Key: {:?}", key); - // TODO: Implement API key logic - Ok(()) -} /// Handle Gitea command async fn handle_gitea( diff --git a/src/processing/handlers.rs b/src/processing/handlers.rs index cbb1b695..deb80ece 100644 --- a/src/processing/handlers.rs +++ b/src/processing/handlers.rs @@ -405,7 +405,7 @@ pub async fn handle_api_key( let database_url = std::env::var("DATABASE_URL") .unwrap_or_else(|_| "postgres://accusys@localhost:5432/momentry".to_string()); let db = PostgresDb::new(&database_url).await?; - let service = ApiKeyService::new(&database_url); + let service = ApiKeyService::new(database_url); match action { crate::cli::args::ApiKeyAction::Create => { @@ -426,7 +426,7 @@ pub async fn handle_api_key( user_id: None, service_name: None, permissions: vec!["read".to_string(), "write".to_string()], // Default permissions - ttl_days: ttl, + ttl_days: ttl.map(|u| u as i64), }; // Generate key