retry webhooks in test mode

pull/669/merge
Pete Matsyburka 1 month ago
parent 45ae954c0c
commit 01dd3fefe5

@ -30,13 +30,12 @@ class SendFormCompletedWebhookRequestJob
attempt:, attempt:,
data: Submitters::SerializeForWebhook.call(submitter)) data: Submitters::SerializeForWebhook.call(submitter))
if (resp.nil? || resp.status.to_i >= 400) && attempt <= MAX_ATTEMPTS && return if attempt > MAX_ATTEMPTS || (resp && resp.status.to_i < 400)
(!Docuseal.multitenant? || submitter.account.account_configs.exists?(key: :plan))
SendFormCompletedWebhookRequestJob.perform_in((2**attempt).minutes, { SendFormCompletedWebhookRequestJob.perform_in((2**attempt).minutes, {
**params, **params,
'attempt' => attempt + 1, 'attempt' => attempt + 1,
'last_status' => resp&.status.to_i 'last_status' => resp&.status.to_i
}) })
end end
end
end end

@ -28,13 +28,12 @@ class SendFormDeclinedWebhookRequestJob
attempt:, attempt:,
data: Submitters::SerializeForWebhook.call(submitter)) data: Submitters::SerializeForWebhook.call(submitter))
if (resp.nil? || resp.status.to_i >= 400) && attempt <= MAX_ATTEMPTS && return if attempt > MAX_ATTEMPTS || (resp && resp.status.to_i < 400)
(!Docuseal.multitenant? || submitter.account.account_configs.exists?(key: :plan))
SendFormDeclinedWebhookRequestJob.perform_in((2**attempt).minutes, { SendFormDeclinedWebhookRequestJob.perform_in((2**attempt).minutes, {
**params, **params,
'attempt' => attempt + 1, 'attempt' => attempt + 1,
'last_status' => resp&.status.to_i 'last_status' => resp&.status.to_i
}) })
end end
end
end end

@ -28,13 +28,12 @@ class SendFormStartedWebhookRequestJob
attempt:, attempt:,
data: Submitters::SerializeForWebhook.call(submitter)) data: Submitters::SerializeForWebhook.call(submitter))
if (resp.nil? || resp.status.to_i >= 400) && attempt <= MAX_ATTEMPTS && return if attempt > MAX_ATTEMPTS || (resp && resp.status.to_i < 400)
(!Docuseal.multitenant? || submitter.account.account_configs.exists?(key: :plan))
SendFormStartedWebhookRequestJob.perform_in((2**attempt).minutes, { SendFormStartedWebhookRequestJob.perform_in((2**attempt).minutes, {
**params, **params,
'attempt' => attempt + 1, 'attempt' => attempt + 1,
'last_status' => resp&.status.to_i 'last_status' => resp&.status.to_i
}) })
end end
end
end end

@ -28,13 +28,12 @@ class SendFormViewedWebhookRequestJob
attempt:, attempt:,
data: Submitters::SerializeForWebhook.call(submitter)) data: Submitters::SerializeForWebhook.call(submitter))
if (resp.nil? || resp.status.to_i >= 400) && attempt <= MAX_ATTEMPTS && return if attempt > MAX_ATTEMPTS || (resp && resp.status.to_i < 400)
(!Docuseal.multitenant? || submitter.account.account_configs.exists?(key: :plan))
SendFormViewedWebhookRequestJob.perform_in((2**attempt).minutes, { SendFormViewedWebhookRequestJob.perform_in((2**attempt).minutes, {
**params, **params,
'attempt' => attempt + 1, 'attempt' => attempt + 1,
'last_status' => resp&.status.to_i 'last_status' => resp&.status.to_i
}) })
end end
end
end end

@ -26,13 +26,12 @@ class SendSubmissionArchivedWebhookRequestJob
attempt:, attempt:,
data: submission.as_json(only: %i[id archived_at])) data: submission.as_json(only: %i[id archived_at]))
if (resp.nil? || resp.status.to_i >= 400) && attempt <= MAX_ATTEMPTS && return if attempt > MAX_ATTEMPTS || (resp && resp.status.to_i < 400)
(!Docuseal.multitenant? || submission.account.account_configs.exists?(key: :plan))
SendSubmissionArchivedWebhookRequestJob.perform_in((2**attempt).minutes, { SendSubmissionArchivedWebhookRequestJob.perform_in((2**attempt).minutes, {
**params, **params,
'attempt' => attempt + 1, 'attempt' => attempt + 1,
'last_status' => resp&.status.to_i 'last_status' => resp&.status.to_i
}) })
end end
end
end end

@ -26,13 +26,12 @@ class SendSubmissionCompletedWebhookRequestJob
attempt:, attempt:,
data: Submissions::SerializeForApi.call(submission)) data: Submissions::SerializeForApi.call(submission))
if (resp.nil? || resp.status.to_i >= 400) && attempt <= MAX_ATTEMPTS && return if attempt > MAX_ATTEMPTS || (resp && resp.status.to_i < 400)
(!Docuseal.multitenant? || submission.account.account_configs.exists?(key: :plan))
SendSubmissionCompletedWebhookRequestJob.perform_in((2**attempt).minutes, { SendSubmissionCompletedWebhookRequestJob.perform_in((2**attempt).minutes, {
**params, **params,
'attempt' => attempt + 1, 'attempt' => attempt + 1,
'last_status' => resp&.status.to_i 'last_status' => resp&.status.to_i
}) })
end end
end
end end

@ -26,13 +26,12 @@ class SendSubmissionCreatedWebhookRequestJob
attempt:, attempt:,
data: Submissions::SerializeForApi.call(submission)) data: Submissions::SerializeForApi.call(submission))
if (resp.nil? || resp.status.to_i >= 400) && attempt <= MAX_ATTEMPTS && return if attempt > MAX_ATTEMPTS || (resp && resp.status.to_i < 400)
(!Docuseal.multitenant? || submission.account.account_configs.exists?(key: :plan))
SendSubmissionCreatedWebhookRequestJob.perform_in((2**attempt).minutes, { SendSubmissionCreatedWebhookRequestJob.perform_in((2**attempt).minutes, {
**params, **params,
'attempt' => attempt + 1, 'attempt' => attempt + 1,
'last_status' => resp&.status.to_i 'last_status' => resp&.status.to_i
}) })
end end
end
end end

@ -26,13 +26,12 @@ class SendSubmissionExpiredWebhookRequestJob
attempt:, attempt:,
data: Submissions::SerializeForApi.call(submission)) data: Submissions::SerializeForApi.call(submission))
if (resp.nil? || resp.status.to_i >= 400) && attempt <= MAX_ATTEMPTS && return if attempt > MAX_ATTEMPTS || (resp && resp.status.to_i < 400)
(!Docuseal.multitenant? || submission.account.account_configs.exists?(key: :plan))
SendSubmissionExpiredWebhookRequestJob.perform_in((2**attempt).minutes, { SendSubmissionExpiredWebhookRequestJob.perform_in((2**attempt).minutes, {
**params, **params,
'attempt' => attempt + 1, 'attempt' => attempt + 1,
'last_status' => resp&.status.to_i 'last_status' => resp&.status.to_i
}) })
end end
end
end end

@ -26,13 +26,12 @@ class SendTemplateArchivedWebhookRequestJob
attempt:, attempt:,
data: template.as_json(only: %i[id archived_at])) data: template.as_json(only: %i[id archived_at]))
if (resp.nil? || resp.status.to_i >= 400) && attempt <= MAX_ATTEMPTS && return if attempt > MAX_ATTEMPTS || (resp && resp.status.to_i < 400)
(!Docuseal.multitenant? || template.account.account_configs.exists?(key: :plan))
SendTemplateArchivedWebhookRequestJob.perform_in((2**attempt).minutes, { SendTemplateArchivedWebhookRequestJob.perform_in((2**attempt).minutes, {
**params, **params,
'attempt' => attempt + 1, 'attempt' => attempt + 1,
'last_status' => resp&.status.to_i 'last_status' => resp&.status.to_i
}) })
end end
end
end end

@ -26,13 +26,12 @@ class SendTemplateCreatedWebhookRequestJob
attempt:, attempt:,
data: Templates::SerializeForApi.call(template)) data: Templates::SerializeForApi.call(template))
if (resp.nil? || resp.status.to_i >= 400) && attempt <= MAX_ATTEMPTS && return if attempt > MAX_ATTEMPTS || (resp && resp.status.to_i < 400)
(!Docuseal.multitenant? || template.account.account_configs.exists?(key: :plan))
SendTemplateCreatedWebhookRequestJob.perform_in((2**attempt).minutes, { SendTemplateCreatedWebhookRequestJob.perform_in((2**attempt).minutes, {
**params, **params,
'attempt' => attempt + 1, 'attempt' => attempt + 1,
'last_status' => resp&.status.to_i 'last_status' => resp&.status.to_i
}) })
end end
end
end end

@ -26,13 +26,12 @@ class SendTemplateUpdatedWebhookRequestJob
attempt:, attempt:,
data: Templates::SerializeForApi.call(template)) data: Templates::SerializeForApi.call(template))
if (resp.nil? || resp.status.to_i >= 400) && attempt <= MAX_ATTEMPTS && return if attempt > MAX_ATTEMPTS || (resp && resp.status.to_i < 400)
(!Docuseal.multitenant? || template.account.account_configs.exists?(key: :plan))
SendTemplateUpdatedWebhookRequestJob.perform_in((2**attempt).minutes, { SendTemplateUpdatedWebhookRequestJob.perform_in((2**attempt).minutes, {
**params, **params,
'attempt' => attempt + 1, 'attempt' => attempt + 1,
'last_status' => resp&.status.to_i 'last_status' => resp&.status.to_i
}) })
end end
end
end end

@ -3,13 +3,14 @@
<% webhook_attempts = webhook_event.webhook_attempts.sort_by { |e| -e.id } %> <% webhook_attempts = webhook_event.webhook_attempts.sort_by { |e| -e.id } %>
<% if webhook_event.status == 'error' %> <% if webhook_event.status == 'error' %>
<% last_attempt = webhook_attempts.select { |e| e.attempt < SendWebhookRequest::MANUAL_ATTEMPT }.max_by(&:attempt) %> <% last_attempt = webhook_attempts.select { |e| e.attempt < SendWebhookRequest::MANUAL_ATTEMPT }.max_by(&:attempt) %>
<% if webhook_event.webhook_attempts.none?(&:success?) && last_attempt.attempt <= 10 %> <% next_attempt_at = last_attempt.created_at + (2**last_attempt.attempt).minutes %>
<% if webhook_event.webhook_attempts.none?(&:success?) && last_attempt.attempt <= 10 && next_attempt_at > 30.seconds.ago %>
<li class="ml-7"> <li class="ml-7">
<span class="btn btn-outline btn-xs btn-circle pointer-events-none absolute justify-center border-base-content-/60 text-base-content/60 bg-base-100" style="left: -12px;"> <span class="btn btn-outline btn-xs btn-circle pointer-events-none absolute justify-center border-base-content-/60 text-base-content/60 bg-base-100" style="left: -12px;">
<%= svg_icon('clock', class: 'w-4 h-4 shrink-0') %> <%= svg_icon('clock', class: 'w-4 h-4 shrink-0') %>
</span> </span>
<p class="leading-none text-base-content/90 pt-1"> <p class="leading-none text-base-content/90 pt-1">
<%= t('next_attempt_in_time_in_words', time_in_words: distance_of_time_in_words(Time.current, last_attempt.created_at + (2**last_attempt.attempt).minutes)) %> <%= t('next_attempt_in_time_in_words', time_in_words: distance_of_time_in_words(Time.current, next_attempt_at)) %>
</p> </p>
</li> </li>
<% end %> <% end %>

Loading…
Cancel
Save