From 1f7b0f1f7e5c2229b54111e0342be7a02427b8bb Mon Sep 17 00:00:00 2001 From: Avikalp Kumar Gupta Date: Tue, 31 Oct 2023 19:31:44 +0530 Subject: [PATCH] fix: github install requests are not directed to the appropriate function --- vibi-dpu/src/github/auth.rs | 3 ++- vibi-dpu/src/pubsub/listener.rs | 25 +++++++------------------ 2 files changed, 9 insertions(+), 19 deletions(-) diff --git a/vibi-dpu/src/github/auth.rs b/vibi-dpu/src/github/auth.rs index a5818b33..358ca8e4 100644 --- a/vibi-dpu/src/github/auth.rs +++ b/vibi-dpu/src/github/auth.rs @@ -20,7 +20,7 @@ struct Claims { } fn generate_jwt(github_app_id: &str) -> Option { - let pem_file_path = "/app/repoprofiler_private.pem"; + let pem_file_path = "/app/repo-profiler.pem"; let pem_data_res = fs::read(pem_file_path); if pem_data_res.is_err() { @@ -85,5 +85,6 @@ pub async fn fetch_access_token(installation_id: &str) -> Option { return None; } let response_json: Value = parse_res.expect("Uncaught error in parse_res for AuthInfo"); + // save_auth_info_to_db(&mut response_json); return Some(response_json); } \ No newline at end of file diff --git a/vibi-dpu/src/pubsub/listener.rs b/vibi-dpu/src/pubsub/listener.rs index 0ed629a8..8ec13f98 100644 --- a/vibi-dpu/src/pubsub/listener.rs +++ b/vibi-dpu/src/pubsub/listener.rs @@ -1,4 +1,5 @@ use crate::{core::bitbucket::setup::handle_install_bitbucket, utils::user::ProviderEnum}; +use crate::core::github::setup::handle_install_github; use crate::core::review::process_review; use crate::db::prs::process_and_update_pr_if_different; use futures_util::StreamExt; @@ -31,18 +32,7 @@ async fn process_message(attributes: &HashMap, data_bytes: &Vec< let msgtype = msgtype_opt.expect("Empty msgtype"); match msgtype.as_str() { "install_callback" => { - println!("Processing install callback message"); - let msg_data_res = serde_json::from_slice::(data_bytes); - if msg_data_res.is_err() { - eprintln!("Error deserializing install callback: {:?}", msg_data_res); - return; - } - let data = msg_data_res.expect("msg_data not found"); - let code_async = data.installation_code.clone(); - task::spawn(async move { - handle_install_bitbucket(&code_async).await; - println!("Processed install callback message"); - }); + process_install_callback(&data_bytes).await; } "webhook_callback" => { let data_bytes_async = data_bytes.to_owned(); @@ -83,12 +73,11 @@ async fn process_install_callback(data_bytes: &[u8]) { } let data = msg_data_res.expect("msg_data not found"); if data.repository_provider == ProviderEnum::Github.to_string().to_lowercase() { - println!("To be Implemented"); - // let code_async = data.installation_code.clone(); - // task::spawn(async move { - // handle_install_github(&code_async).await; - // println!("Processed install callback message"); - // }); + let code_async = data.installation_code.clone(); + task::spawn(async move { + handle_install_github(&code_async).await; + println!("Processed install callback message"); + }); } if data.repository_provider == ProviderEnum::Bitbucket.to_string().to_lowercase() { let code_async = data.installation_code.clone();