@@ -500,6 +500,7 @@ const testItCommands = [
500
500
* issueNumber: number;
501
501
* commentId: number;
502
502
* commentBody: string;
503
+ * commentIsFromIssue: boolean;
503
504
* isPr: boolean;
504
505
* commentUser: string;
505
506
* authorAssociation: AuthorAssociation
@@ -551,6 +552,18 @@ async function webhook(params) {
551
552
return ;
552
553
}
553
554
555
+ log ( `Reacting to ${ params . commentIsFromIssue ? "issue" : "review" } comment ${ params . commentId } ` ) ;
556
+ try {
557
+ const createReaction = params . commentIsFromIssue ? cli . reactions . createForIssueComment : cli . reactions . createForPullRequestReviewComment ;
558
+ await createReaction ( {
559
+ owner : "microsoft" ,
560
+ repo : "TypeScript" ,
561
+ comment_id : params . commentId ,
562
+ content : "+1" ,
563
+ } ) ;
564
+ } catch ( e ) {
565
+ log ( `Failed to react to comment: ${ e } ` ) ;
566
+ }
554
567
555
568
const start = Date . now ( ) ;
556
569
const created = `>=${ new Date ( start ) . toISOString ( ) } ` ;
@@ -700,14 +713,17 @@ async function handler(request, context) {
700
713
context . log ( "Inspecting comment..." ) ;
701
714
702
715
const isNewComment = "action" in event
703
- && ( event . action === "created" || event . action === "submitted" )
704
- && ( "issue" in event || "pull_request" in event ) ;
716
+ && (
717
+ ( event . action === "created" && "issue" in event ) // issue_comment.created
718
+ || ( event . action === "submitted" && "review" in event ) // pull_request_review.submitted
719
+ )
705
720
if ( ! isNewComment ) {
706
721
context . log ( "Not a new comment" )
707
722
return { } ;
708
723
}
709
724
710
- const comment = "comment" in event ? event . comment : event . review ;
725
+ const commentIsFromIssue = "comment" in event ;
726
+ const comment = commentIsFromIssue ? event . comment : event . review ;
711
727
if ( ! comment . body ) {
712
728
context . log ( "No comment body" )
713
729
return { } ;
@@ -726,6 +742,7 @@ async function handler(request, context) {
726
742
issueNumber,
727
743
commentId : comment . id ,
728
744
commentBody : comment . body ,
745
+ commentIsFromIssue,
729
746
isPr,
730
747
commentUser : comment . user . login ,
731
748
authorAssociation : comment . author_association ,
0 commit comments