From eda862f142d88397ed33b1c0fe57d21389647fc3 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Wed, 1 May 2024 09:58:42 -0700 Subject: [PATCH] Set comment created_at/updated_at types to support null. The `review` field of `PullRequestReviewEvent` isn't quite the same as a `Comment`, even though we are pretending they are the same. The `submitted_at` is optional, which was causing deserialization errors. I was inclined to stop treating pull request review comments the same as comments, since their fields don't quite line up. However, that is a much larger change, and generally makes handling pr review comments more awkward. --- src/github.rs | 4 ++-- src/lib.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/github.rs b/src/github.rs index 0ea9704a..012b014d 100644 --- a/src/github.rs +++ b/src/github.rs @@ -363,9 +363,9 @@ pub struct Comment { pub body: String, pub html_url: String, pub user: User, - #[serde(alias = "submitted_at")] // for pull request reviews + #[serde(default, alias = "submitted_at")] // for pull request reviews pub created_at: chrono::DateTime, - #[serde(alias = "submitted_at")] // for pull request reviews + #[serde(default, alias = "submitted_at")] // for pull request reviews pub updated_at: chrono::DateTime, #[serde(default, rename = "state")] pub pr_review_state: Option, diff --git a/src/lib.rs b/src/lib.rs index 2ceb7b59..e3c83e17 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -185,7 +185,7 @@ pub async fn webhook( payload.pull_request.pull_request = Some(PullRequestDetails::new()); // Treat pull request review comments exactly like pull request - // review comments. + // comments. github::Event::IssueComment(github::IssueCommentEvent { action: match payload.action { github::PullRequestReviewAction::Submitted => {