@@ -9,6 +9,8 @@ use interactions::ErrorComment;
9
9
use std:: fmt;
10
10
use tracing as log;
11
11
12
+ use crate :: github:: PullRequestDetails ;
13
+
12
14
pub mod actions;
13
15
pub mod agenda;
14
16
mod changelogs;
@@ -100,12 +102,18 @@ pub async fn webhook(
100
102
) -> Result < bool , WebhookError > {
101
103
let event = match event {
102
104
EventName :: PullRequestReview => {
103
- let payload = deserialize_payload :: < github:: PullRequestReviewEvent > ( & payload)
105
+ let mut payload = deserialize_payload :: < github:: PullRequestReviewEvent > ( & payload)
104
106
. context ( "PullRequestReview failed to deserialize" )
105
107
. map_err ( anyhow:: Error :: from) ?;
106
108
107
109
log:: info!( "handling pull request review comment {:?}" , payload) ;
108
110
111
+ // Github doesn't send a pull_request field nested into the
112
+ // pull_request field, so we need to adjust the deserialized result
113
+ // to preserve that this event came from a pull request (since it's
114
+ // a PR review, that's obviously the case).
115
+ payload. pull_request . pull_request = Some ( PullRequestDetails { } ) ;
116
+
109
117
// Treat pull request review comments exactly like pull request
110
118
// review comments.
111
119
github:: Event :: IssueComment ( github:: IssueCommentEvent {
@@ -125,10 +133,16 @@ pub async fn webhook(
125
133
} )
126
134
}
127
135
EventName :: PullRequestReviewComment => {
128
- let payload = deserialize_payload :: < github:: PullRequestReviewComment > ( & payload)
136
+ let mut payload = deserialize_payload :: < github:: PullRequestReviewComment > ( & payload)
129
137
. context ( "PullRequestReview(Comment) failed to deserialize" )
130
138
. map_err ( anyhow:: Error :: from) ?;
131
139
140
+ // Github doesn't send a pull_request field nested into the
141
+ // pull_request field, so we need to adjust the deserialized result
142
+ // to preserve that this event came from a pull request (since it's
143
+ // a PR review, that's obviously the case).
144
+ payload. issue . pull_request = Some ( PullRequestDetails { } ) ;
145
+
132
146
log:: info!( "handling pull request review comment {:?}" , payload) ;
133
147
134
148
// Treat pull request review comments exactly like pull request
0 commit comments