@@ -30,11 +30,8 @@ export function validateJiraSignature(secret: string, signature: string, body: s
3030 const providedSignature = signature . substring ( 7 )
3131 const computedHash = crypto . createHmac ( 'sha256' , secret ) . update ( body , 'utf8' ) . digest ( 'hex' )
3232 logger . debug ( 'Jira signature comparison' , {
33- computedSignature : `${ computedHash . substring ( 0 , 10 ) } ...` ,
34- providedSignature : `${ providedSignature . substring ( 0 , 10 ) } ...` ,
3533 computedLength : computedHash . length ,
3634 providedLength : providedSignature . length ,
37- match : computedHash === providedSignature ,
3835 } )
3936 return safeCompare ( computedHash , providedSignature )
4037 } catch ( error ) {
@@ -52,17 +49,64 @@ export const jiraHandler: WebhookProviderHandler = {
5249 } ) ,
5350
5451 async formatInput ( { body, webhook } : FormatInputContext ) : Promise < FormatInputResult > {
55- const { extractIssueData, extractCommentData, extractWorklogData } = await import (
56- '@/triggers/jira/utils'
57- )
52+ const {
53+ extractIssueData,
54+ extractCommentData,
55+ extractWorklogData,
56+ extractSprintData,
57+ extractProjectData,
58+ extractVersionData,
59+ } = await import ( '@/triggers/jira/utils' )
5860 const providerConfig = ( webhook . providerConfig as Record < string , unknown > ) || { }
5961 const triggerId = providerConfig . triggerId as string | undefined
60- if ( triggerId === 'jira_issue_commented' ) {
62+
63+ if (
64+ triggerId === 'jira_issue_commented' ||
65+ triggerId === 'jira_comment_updated' ||
66+ triggerId === 'jira_comment_deleted'
67+ ) {
6168 return { input : extractCommentData ( body ) }
6269 }
63- if ( triggerId === 'jira_worklog_created' ) {
70+ if (
71+ triggerId === 'jira_worklog_created' ||
72+ triggerId === 'jira_worklog_updated' ||
73+ triggerId === 'jira_worklog_deleted'
74+ ) {
6475 return { input : extractWorklogData ( body ) }
6576 }
77+ if (
78+ triggerId === 'jira_sprint_created' ||
79+ triggerId === 'jira_sprint_started' ||
80+ triggerId === 'jira_sprint_closed'
81+ ) {
82+ return { input : extractSprintData ( body ) }
83+ }
84+ if ( triggerId === 'jira_project_created' ) {
85+ return { input : extractProjectData ( body ) }
86+ }
87+ if ( triggerId === 'jira_version_released' ) {
88+ return { input : extractVersionData ( body ) }
89+ }
90+
91+ if ( ! triggerId || triggerId === 'jira_webhook' ) {
92+ const obj = body as Record < string , unknown >
93+ return {
94+ input : {
95+ webhookEvent : obj . webhookEvent ,
96+ timestamp : obj . timestamp ,
97+ user : obj . user || null ,
98+ issue_event_type_name : obj . issue_event_type_name ,
99+ issue : obj . issue || { } ,
100+ changelog : obj . changelog ,
101+ comment : obj . comment ,
102+ worklog : obj . worklog ,
103+ sprint : obj . sprint ,
104+ project : obj . project ,
105+ version : obj . version ,
106+ } ,
107+ }
108+ }
109+
66110 return { input : extractIssueData ( body ) }
67111 } ,
68112
@@ -95,9 +139,16 @@ export const jiraHandler: WebhookProviderHandler = {
95139 extractIdempotencyId ( body : unknown ) {
96140 const obj = body as Record < string , unknown >
97141 const issue = obj . issue as Record < string , unknown > | undefined
142+ const comment = obj . comment as Record < string , unknown > | undefined
143+ const worklog = obj . worklog as Record < string , unknown > | undefined
98144 const project = obj . project as Record < string , unknown > | undefined
99- if ( obj . webhookEvent && ( issue ?. id || project ?. id ) ) {
100- return `${ obj . webhookEvent } :${ issue ?. id || project ?. id } `
145+ const sprint = obj . sprint as Record < string , unknown > | undefined
146+ const version = obj . version as Record < string , unknown > | undefined
147+ const entityId =
148+ comment ?. id || worklog ?. id || issue ?. id || project ?. id || sprint ?. id || version ?. id
149+ if ( obj . webhookEvent && entityId ) {
150+ const ts = obj . timestamp ?? ''
151+ return `${ obj . webhookEvent } :${ entityId } :${ ts } `
101152 }
102153 return null
103154 } ,
0 commit comments