Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ use interactions::ErrorComment;
use std::fmt;
use tracing as log;

use crate::github::PullRequestDetails;

pub mod actions;
pub mod agenda;
mod changelogs;
Expand Down Expand Up @@ -100,12 +102,18 @@ pub async fn webhook(
) -> Result<bool, WebhookError> {
let event = match event {
EventName::PullRequestReview => {
let payload = deserialize_payload::<github::PullRequestReviewEvent>(&payload)
let mut payload = deserialize_payload::<github::PullRequestReviewEvent>(&payload)
.context("PullRequestReview failed to deserialize")
.map_err(anyhow::Error::from)?;

log::info!("handling pull request review comment {:?}", payload);

// Github doesn't send a pull_request field nested into the
// pull_request field, so we need to adjust the deserialized result
// to preserve that this event came from a pull request (since it's
// a PR review, that's obviously the case).
payload.pull_request.pull_request = Some(PullRequestDetails {});

// Treat pull request review comments exactly like pull request
// review comments.
github::Event::IssueComment(github::IssueCommentEvent {
Expand All @@ -125,10 +133,16 @@ pub async fn webhook(
})
}
EventName::PullRequestReviewComment => {
let payload = deserialize_payload::<github::PullRequestReviewComment>(&payload)
let mut payload = deserialize_payload::<github::PullRequestReviewComment>(&payload)
.context("PullRequestReview(Comment) failed to deserialize")
.map_err(anyhow::Error::from)?;

// Github doesn't send a pull_request field nested into the
// pull_request field, so we need to adjust the deserialized result
// to preserve that this event came from a pull request (since it's
// a PR review, that's obviously the case).
payload.issue.pull_request = Some(PullRequestDetails {});

log::info!("handling pull request review comment {:?}", payload);

// Treat pull request review comments exactly like pull request
Expand Down