From d62d83ef8eff1dbe2bd3731e26a5e2d49de8ddbf Mon Sep 17 00:00:00 2001 From: Pete Matsyburka Date: Mon, 9 Dec 2024 01:06:57 +0200 Subject: [PATCH] fix duplciate email --- app/controllers/api/submissions_controller.rb | 4 +++- app/jobs/process_submitter_completion_job.rb | 8 ++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/controllers/api/submissions_controller.rb b/app/controllers/api/submissions_controller.rb index 6337a1236..e0de0b4c0 100644 --- a/app/controllers/api/submissions_controller.rb +++ b/app/controllers/api/submissions_controller.rb @@ -78,7 +78,9 @@ def create submissions.each do |submission| submission.submitters.each do |submitter| - ProcessSubmitterCompletionJob.perform_async('submitter_id' => submitter.id) if submitter.completed_at? + next unless submitter.completed_at? + + ProcessSubmitterCompletionJob.perform_async('submitter_id' => submitter.id, 'send_invitation_email' => false) end end diff --git a/app/jobs/process_submitter_completion_job.rb b/app/jobs/process_submitter_completion_job.rb index c23c7f827..5f0d97580 100644 --- a/app/jobs/process_submitter_completion_job.rb +++ b/app/jobs/process_submitter_completion_job.rb @@ -10,10 +10,6 @@ def perform(params = {}) is_all_completed = !submitter.submission.submitters.exists?(completed_at: nil) - if !is_all_completed && submitter.submission.submitters_order_preserved? - enqueue_next_submitter_request_notification(submitter) - end - Submissions::EnsureResultGenerated.call(submitter) if is_all_completed && submitter.completed_at == submitter.submission.submitters.maximum(:completed_at) @@ -28,6 +24,10 @@ def perform(params = {}) create_completed_documents!(submitter) + if !is_all_completed && submitter.submission.submitters_order_preserved? && params['send_invitation_email'] != false + enqueue_next_submitter_request_notification(submitter) + end + enqueue_completed_webhooks(submitter, is_all_completed:) end