@@ -31,25 +31,27 @@ async function main() {
3131
3232 try {
3333 switch ( eventName ) {
34- case "issues" :
34+ case "issues" : {
3535 const issueNumber = context . payload ?. issue ?. number ;
3636 if ( ! issueNumber ) {
3737 core . setFailed ( `${ ERR_NOT_FOUND } : Issue number not found in event payload` ) ;
3838 return ;
3939 }
4040 reactionEndpoint = `/repos/${ owner } /${ repo } /issues/${ issueNumber } /reactions` ;
4141 break ;
42+ }
4243
43- case "issue_comment" :
44+ case "issue_comment" : {
4445 const commentId = context . payload ?. comment ?. id ;
4546 if ( ! commentId ) {
4647 core . setFailed ( `${ ERR_VALIDATION } : Comment ID not found in event payload` ) ;
4748 return ;
4849 }
4950 reactionEndpoint = `/repos/${ owner } /${ repo } /issues/comments/${ commentId } /reactions` ;
5051 break ;
52+ }
5153
52- case "pull_request" :
54+ case "pull_request" : {
5355 const prNumber = context . payload ?. pull_request ?. number ;
5456 if ( ! prNumber ) {
5557 core . setFailed ( `${ ERR_NOT_FOUND } : Pull request number not found in event payload` ) ;
@@ -58,35 +60,39 @@ async function main() {
5860 // PRs are "issues" for the reactions endpoint
5961 reactionEndpoint = `/repos/${ owner } /${ repo } /issues/${ prNumber } /reactions` ;
6062 break ;
63+ }
6164
62- case "pull_request_review_comment" :
65+ case "pull_request_review_comment" : {
6366 const reviewCommentId = context . payload ?. comment ?. id ;
6467 if ( ! reviewCommentId ) {
6568 core . setFailed ( `${ ERR_VALIDATION } : Review comment ID not found in event payload` ) ;
6669 return ;
6770 }
6871 reactionEndpoint = `/repos/${ owner } /${ repo } /pulls/comments/${ reviewCommentId } /reactions` ;
6972 break ;
73+ }
7074
71- case "discussion" :
75+ case "discussion" : {
7276 const discussionNumber = context . payload ?. discussion ?. number ;
7377 if ( ! discussionNumber ) {
7478 core . setFailed ( `${ ERR_NOT_FOUND } : Discussion number not found in event payload` ) ;
7579 return ;
7680 }
7781 // Discussions use GraphQL API - get the node ID
78- const discussion = await getDiscussionId ( owner , repo , discussionNumber ) ;
79- await addDiscussionReaction ( discussion . id , reaction ) ;
82+ const discussionNodeId = await getDiscussionNodeId ( owner , repo , discussionNumber ) ;
83+ await addDiscussionReaction ( discussionNodeId , reaction ) ;
8084 return ; // Early return for discussion events
85+ }
8186
82- case "discussion_comment" :
87+ case "discussion_comment" : {
8388 const commentNodeId = context . payload ?. comment ?. node_id ;
8489 if ( ! commentNodeId ) {
8590 core . setFailed ( `${ ERR_NOT_FOUND } : Discussion comment node ID not found in event payload` ) ;
8691 return ;
8792 }
8893 await addDiscussionReaction ( commentNodeId , reaction ) ;
8994 return ; // Early return for discussion comment events
95+ }
9096
9197 default :
9298 core . setFailed ( `${ ERR_VALIDATION } : Unsupported event type: ${ eventName } ` ) ;
@@ -181,16 +187,15 @@ async function addDiscussionReaction(subjectId, reaction) {
181187 * @param {string } owner - Repository owner
182188 * @param {string } repo - Repository name
183189 * @param {number } discussionNumber - Discussion number
184- * @returns {Promise<{id: string, url: string} > } Discussion details
190+ * @returns {Promise<string> } Discussion node ID
185191 */
186- async function getDiscussionId ( owner , repo , discussionNumber ) {
192+ async function getDiscussionNodeId ( owner , repo , discussionNumber ) {
187193 const { repository } = await github . graphql (
188194 `
189195 query($owner: String!, $repo: String!, $num: Int!) {
190196 repository(owner: $owner, name: $repo) {
191197 discussion(number: $num) {
192198 id
193- url
194199 }
195200 }
196201 }` ,
@@ -201,10 +206,7 @@ async function getDiscussionId(owner, repo, discussionNumber) {
201206 throw new Error ( `${ ERR_NOT_FOUND } : Discussion #${ discussionNumber } not found in ${ owner } /${ repo } ` ) ;
202207 }
203208
204- return {
205- id : repository . discussion . id ,
206- url : repository . discussion . url ,
207- } ;
209+ return repository . discussion . id ;
208210}
209211
210212module . exports = { main } ;
0 commit comments