adjust webhooks

This commit is contained in:
Pete Matsyburka
2024-11-01 15:35:02 +02:00
parent 84edb6dbda
commit 2542f26d96
40 changed files with 156 additions and 235 deletions
@@ -67,10 +67,10 @@ module Api
submissions = create_submissions(@template, params)
@template.account.webhook_urls.with_event('submission.created').each do |webhook_url|
WebhookUrls.for_account_id(@template.account_id, 'submission.created').each do |webhook_url|
submissions.each do |submission|
SendSubmissionCreatedWebhookRequestJob.perform_async({ 'submission_id' => submission.id,
'webhook_url_id' => webhook_url.id })
SendSubmissionCreatedWebhookRequestJob.perform_async('submission_id' => submission.id,
'webhook_url_id' => webhook_url.id)
end
end
@@ -78,7 +78,7 @@ module Api
submissions.each do |submission|
submission.submitters.each do |submitter|
ProcessSubmitterCompletionJob.perform_async({ 'submitter_id' => submitter.id }) if submitter.completed_at?
ProcessSubmitterCompletionJob.perform_async('submitter_id' => submitter.id) if submitter.completed_at?
end
end
@@ -96,9 +96,9 @@ module Api
else
@submission.update!(archived_at: Time.current)
@submission.account.webhook_urls.with_event('submission.archived').each do |webhook_url|
SendSubmissionArchivedWebhookRequestJob.perform_async({ 'submission_id' => @submission.id,
'webhook_url_id' => webhook_url.id })
WebhookUrls.for_account_id(@submission.account_id, 'submission.archived').each do |webhook_url|
SendSubmissionArchivedWebhookRequestJob.perform_async('submission_id' => @submission.id,
'webhook_url_id' => webhook_url.id)
end
end
@@ -13,9 +13,9 @@ module Api
SubmissionEvents.create_with_tracking_data(submitter, 'view_form', request)
submitter.account.webhook_urls.with_event('form.viewed').each do |webhook_url|
SendFormViewedWebhookRequestJob.perform_async({ 'submitter_id' => submitter.id,
'webhook_url_id' => webhook_url.id })
WebhookUrls.for_account_id(submitter.account_id, 'form.viewed').each do |webhook_url|
SendFormViewedWebhookRequestJob.perform_async('submitter_id' => submitter.id,
'webhook_url_id' => webhook_url.id)
end
render json: {}
+1 -1
View File
@@ -68,7 +68,7 @@ module Api
end
if @submitter.completed_at?
ProcessSubmitterCompletionJob.perform_async({ 'submitter_id' => @submitter.id })
ProcessSubmitterCompletionJob.perform_async('submitter_id' => @submitter.id)
elsif normalized_params[:send_email] || normalized_params[:send_sms]
Submitters.send_signature_requests([@submitter])
end
@@ -25,9 +25,9 @@ module Api
schema_documents = Templates::CloneAttachments.call(template: cloned_template, original_template: @template)
cloned_template.account.webhook_urls.with_event('template.created').each do |webhook_url|
SendTemplateCreatedWebhookRequestJob.perform_async({ 'template_id' => cloned_template.id,
'webhook_url_id' => webhook_url.id })
WebhookUrls.for_account_id(cloned_template.account_id, 'template.created').each do |webhook_url|
SendTemplateCreatedWebhookRequestJob.perform_async('template_id' => cloned_template.id,
'webhook_url_id' => webhook_url.id)
end
render json: Templates::SerializeForApi.call(cloned_template, schema_documents)
+3 -3
View File
@@ -65,9 +65,9 @@ module Api
@template.update!(template_params)
@template.account.webhook_urls.with_event('template.updated').each do |webhook_url|
SendTemplateUpdatedWebhookRequestJob.perform_async({ 'template_id' => @template.id,
'webhook_url_id' => webhook_url.id })
WebhookUrls.for_account_id(@template.account_id, 'template.updated').each do |webhook_url|
SendTemplateUpdatedWebhookRequestJob.perform_async('template_id' => @template.id,
'webhook_url_id' => webhook_url.id)
end
render json: @template.as_json(only: %i[id updated_at])