@@ -9,7 +9,7 @@ const { ERR_API, ERR_NOT_FOUND, ERR_VALIDATION } = require("./error_codes.cjs");
99const { buildWorkflowRunUrl } = require ( "./workflow_metadata_helpers.cjs" ) ;
1010const { resolveTopLevelDiscussionCommentId } = require ( "./github_api_helpers.cjs" ) ;
1111const { resolveInvocationContext } = require ( "./invocation_context_helpers.cjs" ) ;
12- const { addReaction, addDiscussionReaction } = require ( "./add_reaction.cjs" ) ;
12+ const { addReaction, addDiscussionReaction, getDiscussionNodeId } = require ( "./add_reaction.cjs" ) ;
1313
1414/**
1515 * Event type descriptions for comment messages
@@ -106,9 +106,9 @@ async function resolveEventEndpoints(eventName, owner, repo, payload) {
106106 return null ;
107107 }
108108 // Discussions use GraphQL API - get the node ID
109- const discussion = await getDiscussionId ( owner , repo , discussionNumber ) ;
109+ const discussionNodeId = await getDiscussionNodeId ( owner , repo , discussionNumber ) ;
110110 return {
111- reactionEndpoint : discussion . id , // Store node ID for GraphQL
111+ reactionEndpoint : discussionNodeId , // Store node ID for GraphQL
112112 commentUpdateEndpoint : `discussion:${ discussionNumber } ` , // Special format to indicate discussion
113113 } ;
114114 }
@@ -186,37 +186,6 @@ async function main() {
186186 }
187187}
188188
189- /**
190- * Get the node ID for a discussion
191- * @param {string } owner - Repository owner
192- * @param {string } repo - Repository name
193- * @param {number } discussionNumber - Discussion number
194- * @returns {Promise<{id: string, url: string}> } Discussion details
195- */
196- async function getDiscussionId ( owner , repo , discussionNumber ) {
197- const { repository } = await github . graphql (
198- `
199- query($owner: String!, $repo: String!, $num: Int!) {
200- repository(owner: $owner, name: $repo) {
201- discussion(number: $num) {
202- id
203- url
204- }
205- }
206- }` ,
207- { owner, repo, num : discussionNumber }
208- ) ;
209-
210- if ( ! repository || ! repository . discussion ) {
211- throw new Error ( `${ ERR_NOT_FOUND } : Discussion #${ discussionNumber } not found in ${ owner } /${ repo } ` ) ;
212- }
213-
214- return {
215- id : repository . discussion . id ,
216- url : repository . discussion . url ,
217- } ;
218- }
219-
220189/**
221190 * Helper function to set comment outputs
222191 * @param {string } commentId - The comment ID
@@ -277,7 +246,7 @@ async function addCommentWithWorkflowLink(endpoint, runUrl, eventName, invocatio
277246 if ( eventName === "discussion" || eventName === "discussion_comment" ) {
278247 // Parse discussion number from special format: "discussion:NUMBER" or "discussion_comment:NUMBER:COMMENT_ID"
279248 const discussionNumber = parseInt ( endpoint . split ( ":" ) [ 1 ] , 10 ) ;
280- const { id : discussionId } = await getDiscussionId ( eventRepo . owner , eventRepo . repo , discussionNumber ) ;
249+ const discussionId = await getDiscussionNodeId ( eventRepo . owner , eventRepo . repo , discussionNumber ) ;
281250 // For discussion_comment events, thread the reply under the triggering comment.
282251 // GitHub Discussions only supports two nesting levels, so resolve the top-level parent node ID.
283252 const replyToId = eventName === "discussion_comment" ? await resolveTopLevelDiscussionCommentId ( github , eventPayload ?. comment ?. node_id ) : null ;
0 commit comments