Browse Source

Handle missing pr_review_state in comments

This hopefully fixes the failures to deserialize issue comments.
Mark Rousskov 3 years ago
parent
commit
93f376232f
2 changed files with 3 additions and 3 deletions
  1. 2 2
      src/github.rs
  2. 1 1
      src/handlers/review_submitted.rs

+ 2 - 2
src/github.rs

@@ -292,8 +292,8 @@ pub struct Comment {
     pub user: User,
     #[serde(alias = "submitted_at")] // for pull request reviews
     pub updated_at: chrono::DateTime<Utc>,
-    #[serde(rename = "state")]
-    pub pr_review_state: PullRequestReviewState,
+    #[serde(default, rename = "state")]
+    pub pr_review_state: Option<PullRequestReviewState>,
 }
 
 #[derive(Debug, serde::Deserialize, Eq, PartialEq)]

+ 1 - 1
src/handlers/review_submitted.rs

@@ -19,7 +19,7 @@ pub(crate) async fn handle(
         },
     ) = event
     {
-        if event.comment.pr_review_state != PullRequestReviewState::ChangesRequested {
+        if event.comment.pr_review_state != Some(PullRequestReviewState::ChangesRequested) {
             return Ok(());
         }