|
|
|
|
@ -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
|
|
|
|
|
|