fix(core): Streamline multiple pinned triggers behavior (#4569)

🐛 Fix multiple pinned triggers behavior
This commit is contained in:
Iván Ovejero
2022-11-10 14:03:14 +01:00
committed by GitHub
parent d06197d879
commit 953457ad86
2 changed files with 27 additions and 17 deletions

View File

@@ -1,7 +1,7 @@
/* eslint-disable no-param-reassign */
import express from 'express';
import { INode, IPinData, LoggerProxy, Workflow } from 'n8n-workflow';
import { INode, LoggerProxy, Workflow } from 'n8n-workflow';
import axios from 'axios';
import * as ActiveWorkflowRunner from '@/ActiveWorkflowRunner';
@@ -18,7 +18,6 @@ import {
IWorkflowResponse,
IExecutionPushResponse,
IWorkflowExecutionDataProcess,
IWorkflowDb,
} from '@/Interfaces';
import config from '@/config';
import * as TagHelpers from '@/TagHelpers';
@@ -49,18 +48,6 @@ workflowsController.use((req, res, next) => {
workflowsController.use('/', EEWorkflowController);
const isTrigger = (nodeType: string) =>
['trigger', 'webhook'].some((suffix) => nodeType.toLowerCase().includes(suffix));
function findFirstPinnedTrigger(workflow: IWorkflowDb, pinData?: IPinData) {
if (!pinData) return;
// eslint-disable-next-line consistent-return
return workflow.nodes.find(
(node) => !node.disabled && isTrigger(node.type) && pinData[node.name],
);
}
/**
* POST /workflows
*/
@@ -351,11 +338,11 @@ workflowsController.post(
const sessionId = GenericHelpers.getSessionId(req);
const pinnedTrigger = findFirstPinnedTrigger(workflowData, pinData);
const pinnedTrigger = WorkflowsService.findPinnedTrigger(workflowData, startNodes, pinData);
// If webhooks nodes exist and are active we have to wait for till we receive a call
if (
pinnedTrigger === undefined &&
pinnedTrigger === null &&
(runData === undefined ||
startNodes === undefined ||
startNodes.length === 0 ||