fix: duplicate workflow reminders caused by scanWorkflowBody (#21767)
* don't scan if there is newer task * create seperate tasks per workflowStepId * revert changed constant * fix comment * add back missing import * code clean up * fix PR feedback * change function to hasNewerScanTaskForStepId --------- Co-authored-by: CarinaWolli <[email protected]> Co-authored-by: Anik Dhabal Babu <[email protected]>
This commit is contained in:
3 files changed
+63
-12
No files matched your search
@@ -392,7 +392,11 @@ export const updateHandler = async ({ ctx, input }: UpdateOptions) => {
|
||||
});
|
||||
|
||||
if (SCANNING_WORKFLOW_STEPS && didBodyChange) {
|
||||
await tasker.create("scanWorkflowBody", { workflowStepIds: [oldStep.id], userId: ctx.user.id });
|
||||
await tasker.create("scanWorkflowBody", {
|
||||
workflowStepId: oldStep.id,
|
||||
userId: ctx.user.id,
|
||||
createdAt: new Date().toISOString(),
|
||||
});
|
||||
} else {
|
||||
// schedule notifications for edited steps
|
||||
await scheduleWorkflowNotifications({
|
||||
@@ -467,11 +471,15 @@ export const updateHandler = async ({ ctx, input }: UpdateOptions) => {
|
||||
);
|
||||
|
||||
if (SCANNING_WORKFLOW_STEPS) {
|
||||
// workflows are scanned then scheduled in the task
|
||||
await tasker.create("scanWorkflowBody", {
|
||||
workflowStepIds: createdSteps.map((step) => step.id),
|
||||
userId: ctx.user.id,
|
||||
});
|
||||
await Promise.all(
|
||||
createdSteps.map((step) =>
|
||||
tasker.create("scanWorkflowBody", {
|
||||
workflowStepId: step.id,
|
||||
userId: ctx.user.id,
|
||||
createdAt: new Date().toISOString(),
|
||||
})
|
||||
)
|
||||
);
|
||||
} else {
|
||||
// schedule notification for new step
|
||||
await scheduleWorkflowNotifications({
|
||||
|
||||
Reference in new issue
Block a user