fix(core): Fix pinned trigger execution (#3895)

🐛 Fix pinned trigger execution
This commit is contained in:
Iván Ovejero 2022-08-19 17:52:05 +02:00 committed by GitHub
parent 329fe9581f
commit 17799cda46
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2874,19 +2874,11 @@ function isOAuth(credType: ICredentialType) {
);
}
const TRIGGER_NODE_SUFFIXES = ['trigger', 'webhook'];
const isTrigger = (str: string) =>
TRIGGER_NODE_SUFFIXES.some((suffix) => str.toLowerCase().includes(suffix));
const isTrigger = (nodeType: string) =>
['trigger', 'webhook'].some((suffix) => nodeType.toLowerCase().includes(suffix));
function findFirstPinnedTrigger(workflow: IWorkflowDb, pinData?: IPinData) {
if (!pinData) return;
const firstPinnedTriggerName = Object.keys(pinData).find(isTrigger);
if (!firstPinnedTriggerName) return;
return workflow.nodes.find(
({ type, name }) => isTrigger(type) && name === firstPinnedTriggerName,
);
return workflow.nodes.find((node) => isTrigger(node.type) && pinData[node.name]);
}