feat: Implement webhook logic along with new entry typeform trigger

This commit is contained in:
Faruk AYDIN
2022-11-28 23:30:03 +01:00
committed by Ali BARIN
parent 397926f994
commit d83e8dabf8
13 changed files with 246 additions and 12 deletions

View File

@@ -1,6 +1,7 @@
import Context from '../../types/express/context';
import flowQueue from '../../queues/flow';
import { REMOVE_AFTER_30_DAYS_OR_150_JOBS, REMOVE_AFTER_7_DAYS_OR_50_JOBS } from '../../helpers/remove-job-configuration';
import globalVariable from '../../helpers/global-variable';
type Params = {
input: {
@@ -50,12 +51,22 @@ const updateFlowStatus = async (
jobName,
{ flowId: flow.id },
{
repeat: repeatOptions,
repeat: trigger.type === 'webhook' ? null : repeatOptions,
jobId: flow.id,
removeOnComplete: REMOVE_AFTER_7_DAYS_OR_50_JOBS,
removeOnFail: REMOVE_AFTER_30_DAYS_OR_150_JOBS
}
);
} else if (!flow.active && trigger.type === 'webhook') {
const $ = await globalVariable({
flow,
connection: await triggerStep.$relatedQuery('connection'),
app: await triggerStep.getApp(),
step: triggerStep,
testRun: false,
});
await trigger.unregisterHook($);
} else {
const repeatableJobs = await flowQueue.getRepeatableJobs();
const job = repeatableJobs.find((job) => job.id === flow.id);