Skip to content

Commit

Permalink
fix: github install requests are not directed to the appropriate func…
Browse files Browse the repository at this point in the history
…tion
  • Loading branch information
avikalpg committed Oct 31, 2023
1 parent e9779e3 commit 1f7b0f1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 19 deletions.
3 changes: 2 additions & 1 deletion vibi-dpu/src/github/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ struct Claims {
}

fn generate_jwt(github_app_id: &str) -> Option<String> {
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() {
Expand Down Expand Up @@ -85,5 +85,6 @@ pub async fn fetch_access_token(installation_id: &str) -> Option<Value> {
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);
}
25 changes: 7 additions & 18 deletions vibi-dpu/src/pubsub/listener.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -31,18 +32,7 @@ async fn process_message(attributes: &HashMap<String, String>, 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::<InstallCallback>(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();
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 1f7b0f1

Please sign in to comment.