chore: add comments in update flow status
This commit is contained in:
@@ -41,6 +41,7 @@ const updateFlowStatus = async (
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (flow.active) {
|
if (flow.active) {
|
||||||
|
// add the flow job in the queue.
|
||||||
flow = await flow.$query().patchAndFetch({
|
flow = await flow.$query().patchAndFetch({
|
||||||
published_at: new Date().toISOString(),
|
published_at: new Date().toISOString(),
|
||||||
});
|
});
|
||||||
@@ -51,6 +52,7 @@ const updateFlowStatus = async (
|
|||||||
jobName,
|
jobName,
|
||||||
{ flowId: flow.id },
|
{ flowId: flow.id },
|
||||||
{
|
{
|
||||||
|
// do not repeat webhook job for immediate webhook registration
|
||||||
repeat: trigger.type === 'webhook' ? null : repeatOptions,
|
repeat: trigger.type === 'webhook' ? null : repeatOptions,
|
||||||
jobId: flow.id,
|
jobId: flow.id,
|
||||||
removeOnComplete: REMOVE_AFTER_7_DAYS_OR_50_JOBS,
|
removeOnComplete: REMOVE_AFTER_7_DAYS_OR_50_JOBS,
|
||||||
@@ -58,6 +60,7 @@ const updateFlowStatus = async (
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
} else if (!flow.active && trigger.type === 'webhook') {
|
} else if (!flow.active && trigger.type === 'webhook') {
|
||||||
|
// unregister webhook from the application
|
||||||
const $ = await globalVariable({
|
const $ = await globalVariable({
|
||||||
flow,
|
flow,
|
||||||
connection: await triggerStep.$relatedQuery('connection'),
|
connection: await triggerStep.$relatedQuery('connection'),
|
||||||
@@ -68,6 +71,7 @@ const updateFlowStatus = async (
|
|||||||
|
|
||||||
await trigger.unregisterHook($);
|
await trigger.unregisterHook($);
|
||||||
} else {
|
} else {
|
||||||
|
// remove the job out of the queue
|
||||||
const repeatableJobs = await flowQueue.getRepeatableJobs();
|
const repeatableJobs = await flowQueue.getRepeatableJobs();
|
||||||
const job = repeatableJobs.find((job) => job.id === flow.id);
|
const job = repeatableJobs.find((job) => job.id === flow.id);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user