From ebbde45a9d94495163525673430cb456b6f44c4e Mon Sep 17 00:00:00 2001 From: Avikalp Kumar Gupta Date: Mon, 30 Oct 2023 12:51:52 +0530 Subject: [PATCH] bug fix: flow in webhook callback didn't run process_review on pr update, and didn't run update-pr-in-db on creation --- vibi-dpu/src/db/prs.rs | 1 - vibi-dpu/src/pubsub/listener.rs | 7 ++++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/vibi-dpu/src/db/prs.rs b/vibi-dpu/src/db/prs.rs index 89b28ef3..9e0523b1 100644 --- a/vibi-dpu/src/db/prs.rs +++ b/vibi-dpu/src/db/prs.rs @@ -1,6 +1,5 @@ use serde_json::Value; use sled::IVec; -use std::error::Error; use crate::db::config::get_db; use crate::utils::pr_info::PrInfo; diff --git a/vibi-dpu/src/pubsub/listener.rs b/vibi-dpu/src/pubsub/listener.rs index 618b0ea4..a34b1abe 100644 --- a/vibi-dpu/src/pubsub/listener.rs +++ b/vibi-dpu/src/pubsub/listener.rs @@ -55,11 +55,12 @@ async fn process_message(attributes: &HashMap, data_bytes: &Vec< let pr_number = deserialised_msg_data["eventPayload"]["pullrequest"]["id"].to_string().trim_matches('"').to_string(); let event_type = deserialised_msg_data["eventType"].to_string().trim_matches('"').to_string(); let mut is_reviewable = false; + is_reviewable = process_and_update_pr_if_different(&deserialised_msg_data["eventPayload"], &workspace_slug, &repo_slug, &pr_number, &repo_provider).await; - if event_type == "pullrequest:updated" { - is_reviewable = process_and_update_pr_if_different(&deserialised_msg_data["eventPayload"], &workspace_slug, &repo_slug, &pr_number, &repo_provider).await; + if event_type == "pullrequest:approved" { + todo!("Process approved event"); } - if is_reviewable || event_type == "pullrequest:created" || event_type == "pullrequest:approved" { + if is_reviewable || event_type == "pullrequest:created" || event_type == "pullrequest:updated" { task::spawn(async move { process_review(&data_bytes_async).await; println!("Processed webhook callback message");