simplify job params
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class ProcessSubmitterCompletionJob < ApplicationJob
|
||||
def perform(submitter)
|
||||
def perform(params = {})
|
||||
submitter = Submitter.find(params['submitter_id'])
|
||||
|
||||
is_all_completed = !submitter.submission.submitters.exists?(completed_at: nil)
|
||||
|
||||
if !is_all_completed && submitter.submission.submitters_order_preserved?
|
||||
@@ -18,7 +20,7 @@ class ProcessSubmitterCompletionJob < ApplicationJob
|
||||
|
||||
return if Accounts.load_webhook_url(submitter.account).blank?
|
||||
|
||||
SendFormCompletedWebhookRequestJob.perform_later(submitter)
|
||||
SendFormCompletedWebhookRequestJob.perform_later({ 'submitter_id' => submitter.id })
|
||||
end
|
||||
|
||||
def enqueue_completed_emails(submitter)
|
||||
|
||||
@@ -7,8 +7,10 @@ class SendFormCompletedWebhookRequestJob < ApplicationJob
|
||||
|
||||
MAX_ATTEMPTS = 10
|
||||
|
||||
def perform(submitter, params = {})
|
||||
attempt = params[:attempt].to_i
|
||||
def perform(params = {})
|
||||
submitter = Submitter.find(params['submitter_id'])
|
||||
|
||||
attempt = params['attempt'].to_i
|
||||
url = Accounts.load_webhook_url(submitter.submission.account)
|
||||
|
||||
return if url.blank?
|
||||
@@ -37,9 +39,10 @@ class SendFormCompletedWebhookRequestJob < ApplicationJob
|
||||
if (resp.nil? || resp.status.to_i >= 400) && attempt <= MAX_ATTEMPTS &&
|
||||
(!Docuseal.multitenant? || submitter.account.account_configs.exists?(key: :plan))
|
||||
SendFormCompletedWebhookRequestJob.set(wait: (2**attempt).minutes)
|
||||
.perform_later(submitter, {
|
||||
attempt: attempt + 1,
|
||||
last_status: resp&.status.to_i
|
||||
.perform_later({
|
||||
'submitter_id' => submitter.id,
|
||||
'attempt' => attempt + 1,
|
||||
'last_status' => resp&.status.to_i
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
@@ -7,8 +7,10 @@ class SendFormStartedWebhookRequestJob < ApplicationJob
|
||||
|
||||
MAX_ATTEMPTS = 10
|
||||
|
||||
def perform(submitter, params = {})
|
||||
attempt = params[:attempt].to_i
|
||||
def perform(params = {})
|
||||
submitter = Submitter.find(params['submitter_id'])
|
||||
|
||||
attempt = params['attempt'].to_i
|
||||
url = Accounts.load_webhook_url(submitter.submission.account)
|
||||
|
||||
return if url.blank?
|
||||
@@ -35,9 +37,10 @@ class SendFormStartedWebhookRequestJob < ApplicationJob
|
||||
if (resp.nil? || resp.status.to_i >= 400) && attempt <= MAX_ATTEMPTS &&
|
||||
(!Docuseal.multitenant? || submitter.account.account_configs.exists?(key: :plan))
|
||||
SendFormStartedWebhookRequestJob.set(wait: (2**attempt).minutes)
|
||||
.perform_later(submitter, {
|
||||
attempt: attempt + 1,
|
||||
last_status: resp&.status.to_i
|
||||
.perform_later({
|
||||
'submitter_id' => submitter.id,
|
||||
'attempt' => attempt + 1,
|
||||
'last_status' => resp&.status.to_i
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
@@ -7,8 +7,10 @@ class SendFormViewedWebhookRequestJob < ApplicationJob
|
||||
|
||||
MAX_ATTEMPTS = 10
|
||||
|
||||
def perform(submitter, params = {})
|
||||
attempt = params[:attempt].to_i
|
||||
def perform(params = {})
|
||||
submitter = Submitter.find(params['submitter_id'])
|
||||
|
||||
attempt = params['attempt'].to_i
|
||||
url = Accounts.load_webhook_url(submitter.submission.account)
|
||||
|
||||
return if url.blank?
|
||||
@@ -35,9 +37,10 @@ class SendFormViewedWebhookRequestJob < ApplicationJob
|
||||
if (resp.nil? || resp.status.to_i >= 400) && attempt <= MAX_ATTEMPTS &&
|
||||
(!Docuseal.multitenant? || submitter.account.account_configs.exists?(key: :plan))
|
||||
SendFormViewedWebhookRequestJob.set(wait: (2**attempt).minutes)
|
||||
.perform_later(submitter, {
|
||||
attempt: attempt + 1,
|
||||
last_status: resp&.status.to_i
|
||||
.perform_later({
|
||||
'submitter_id' => submitter.id,
|
||||
'attempt' => attempt + 1,
|
||||
'last_status' => resp&.status.to_i
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
@@ -7,8 +7,10 @@ class SendSubmissionArchivedWebhookRequestJob < ApplicationJob
|
||||
|
||||
MAX_ATTEMPTS = 10
|
||||
|
||||
def perform(submission, params = {})
|
||||
attempt = params[:attempt].to_i
|
||||
def perform(params = {})
|
||||
submission = Submission.find(params['submission_id'])
|
||||
|
||||
attempt = params['attempt'].to_i
|
||||
url = Accounts.load_webhook_url(submission.account)
|
||||
|
||||
return if url.blank?
|
||||
@@ -33,9 +35,10 @@ class SendSubmissionArchivedWebhookRequestJob < ApplicationJob
|
||||
if (resp.nil? || resp.status.to_i >= 400) && attempt <= MAX_ATTEMPTS &&
|
||||
(!Docuseal.multitenant? || submission.account.account_configs.exists?(key: :plan))
|
||||
SendSubmissionArchivedWebhookRequestJob.set(wait: (2**attempt).minutes)
|
||||
.perform_later(submission, {
|
||||
attempt: attempt + 1,
|
||||
last_status: resp&.status.to_i
|
||||
.perform_later({
|
||||
'submission_id' => submission.id,
|
||||
'attempt' => attempt + 1,
|
||||
'last_status' => resp&.status.to_i
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
@@ -7,8 +7,10 @@ class SendSubmissionCreatedWebhookRequestJob < ApplicationJob
|
||||
|
||||
MAX_ATTEMPTS = 10
|
||||
|
||||
def perform(submission, params = {})
|
||||
attempt = params[:attempt].to_i
|
||||
def perform(params = {})
|
||||
submission = Submission.find(params['submission_id'])
|
||||
|
||||
attempt = params['attempt'].to_i
|
||||
url = Accounts.load_webhook_url(submission.account)
|
||||
|
||||
return if url.blank?
|
||||
@@ -33,9 +35,10 @@ class SendSubmissionCreatedWebhookRequestJob < ApplicationJob
|
||||
if (resp.nil? || resp.status.to_i >= 400) && attempt <= MAX_ATTEMPTS &&
|
||||
(!Docuseal.multitenant? || submission.account.account_configs.exists?(key: :plan))
|
||||
SendSubmissionCreatedWebhookRequestJob.set(wait: (2**attempt).minutes)
|
||||
.perform_later(submission, {
|
||||
attempt: attempt + 1,
|
||||
last_status: resp&.status.to_i
|
||||
.perform_later({
|
||||
'submission_id' => submission.id,
|
||||
'attempt' => attempt + 1,
|
||||
'last_status' => resp&.status.to_i
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
@@ -7,8 +7,10 @@ class SendTemplateCreatedWebhookRequestJob < ApplicationJob
|
||||
|
||||
MAX_ATTEMPTS = 10
|
||||
|
||||
def perform(template, params = {})
|
||||
attempt = params[:attempt].to_i
|
||||
def perform(params = {})
|
||||
template = Template.find(params['template_id'])
|
||||
|
||||
attempt = params['attempt'].to_i
|
||||
url = Accounts.load_webhook_url(template.account)
|
||||
|
||||
return if url.blank?
|
||||
@@ -33,9 +35,10 @@ class SendTemplateCreatedWebhookRequestJob < ApplicationJob
|
||||
if (resp.nil? || resp.status.to_i >= 400) && attempt <= MAX_ATTEMPTS &&
|
||||
(!Docuseal.multitenant? || template.account.account_configs.exists?(key: :plan))
|
||||
SendTemplateCreatedWebhookRequestJob.set(wait: (2**attempt).minutes)
|
||||
.perform_later(template, {
|
||||
attempt: attempt + 1,
|
||||
last_status: resp&.status.to_i
|
||||
.perform_later({
|
||||
'template_id' => template.id,
|
||||
'attempt' => attempt + 1,
|
||||
'last_status' => resp&.status.to_i
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
@@ -7,8 +7,10 @@ class SendTemplateUpdatedWebhookRequestJob < ApplicationJob
|
||||
|
||||
MAX_ATTEMPTS = 10
|
||||
|
||||
def perform(template, params = {})
|
||||
attempt = params[:attempt].to_i
|
||||
def perform(params = {})
|
||||
template = Template.find(params['template_id'])
|
||||
|
||||
attempt = params['attempt'].to_i
|
||||
url = Accounts.load_webhook_url(template.account)
|
||||
|
||||
return if url.blank?
|
||||
@@ -33,9 +35,10 @@ class SendTemplateUpdatedWebhookRequestJob < ApplicationJob
|
||||
if (resp.nil? || resp.status.to_i >= 400) && attempt <= MAX_ATTEMPTS &&
|
||||
(!Docuseal.multitenant? || template.account.account_configs.exists?(key: :plan))
|
||||
SendTemplateUpdatedWebhookRequestJob.set(wait: (2**attempt).minutes)
|
||||
.perform_later(template, {
|
||||
attempt: attempt + 1,
|
||||
last_status: resp&.status.to_i
|
||||
.perform_later({
|
||||
'template_id' => template.id,
|
||||
'attempt' => attempt + 1,
|
||||
'last_status' => resp&.status.to_i
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user