mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
fix(Jira Trigger Node): Fix Jira webhook subscriptions on Jira v10+ (#14333)
This commit is contained in:
@@ -11,6 +11,8 @@ import type {
|
||||
} from 'n8n-workflow';
|
||||
import { NodeApiError } from 'n8n-workflow';
|
||||
|
||||
import type { JiraServerInfo, JiraWebhook } from './types';
|
||||
|
||||
export async function jiraSoftwareCloudApiRequest(
|
||||
this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions,
|
||||
endpoint: string,
|
||||
@@ -122,8 +124,9 @@ export function eventExists(currentEvents: string[], webhookEvents: string[]) {
|
||||
return true;
|
||||
}
|
||||
|
||||
export function getId(url: string) {
|
||||
return url.split('/').pop();
|
||||
export function getWebhookId(webhook: JiraWebhook) {
|
||||
if (webhook.id) return webhook.id.toString();
|
||||
return webhook.self?.split('/').pop();
|
||||
}
|
||||
|
||||
export function simplifyIssueOutput(responseData: {
|
||||
@@ -266,3 +269,22 @@ export async function getUsers(this: ILoadOptionsFunctions): Promise<INodeProper
|
||||
return a.name.toLowerCase() > b.name.toLowerCase() ? 1 : -1;
|
||||
});
|
||||
}
|
||||
|
||||
export async function getServerInfo(this: IHookFunctions) {
|
||||
return await (jiraSoftwareCloudApiRequest.call(
|
||||
this,
|
||||
'/api/2/serverInfo',
|
||||
'GET',
|
||||
) as Promise<JiraServerInfo>);
|
||||
}
|
||||
|
||||
export async function getWebhookEndpoint(this: IHookFunctions) {
|
||||
const serverInfo = await getServerInfo.call(this).catch(() => null);
|
||||
|
||||
if (!serverInfo || serverInfo.deploymentType === 'Cloud') return '/webhooks/1.0/webhook';
|
||||
|
||||
// Assume old version when versionNumbers is not set
|
||||
const majorVersion = serverInfo.versionNumbers?.[0] ?? 1;
|
||||
|
||||
return majorVersion >= 10 ? '/jira-webhook/1.0/webhooks' : '/webhooks/1.0/webhook';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user