simplify job params

This commit is contained in:
Pete Matsyburka
2024-06-22 10:36:32 +03:00
parent 61da477733
commit acf06084bf
19 changed files with 78 additions and 53 deletions
@@ -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