Skip to content

Commit

Permalink
Set comment created_at/updated_at types to support null.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ehuss committed May 1, 2024
1 parent c172142 commit eda862f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/github.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Utc>,
#[serde(alias = "submitted_at")] // for pull request reviews
#[serde(default, alias = "submitted_at")] // for pull request reviews
pub updated_at: chrono::DateTime<Utc>,
#[serde(default, rename = "state")]
pub pr_review_state: Option<PullRequestReviewState>,
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down

0 comments on commit eda862f

Please sign in to comment.