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
@@ -64,14 +64,14 @@ module Api
submissions = create_submissions(@template, params)
submissions.each do |submission|
SendSubmissionCreatedWebhookRequestJob.perform_later(submission)
SendSubmissionCreatedWebhookRequestJob.perform_later({ 'submission_id' => submission.id })
end
Submissions.send_signature_requests(submissions)
submissions.each do |submission|
if submission.submitters.all?(&:completed_at?) && submission.submitters.last
ProcessSubmitterCompletionJob.perform_later(submission.submitters.last)
ProcessSubmitterCompletionJob.perform_later({ 'submitter_id' => submission.submitters.last.id })
end
end
@@ -94,7 +94,7 @@ module Api
else
@submission.update!(archived_at: Time.current)
SendSubmissionArchivedWebhookRequestJob.perform_later(@submission)
SendSubmissionArchivedWebhookRequestJob.perform_later('submission_id' => @submission.id)
end
render json: @submission.as_json(only: %i[id archived_at])
@@ -13,7 +13,7 @@ module Api
SubmissionEvents.create_with_tracking_data(submitter, 'view_form', request)
SendFormViewedWebhookRequestJob.perform_later(submitter)
SendFormViewedWebhookRequestJob.perform_later({ 'submitter_id' => submitter.id })
render json: {}
end
+1 -1
View File
@@ -66,7 +66,7 @@ module Api
end
if @submitter.completed_at?
ProcessSubmitterCompletionJob.perform_later(@submitter)
ProcessSubmitterCompletionJob.perform_later({ 'submitter_id' => @submitter.id })
elsif normalized_params[:send_email] || normalized_params[:send_sms]
Submitters.send_signature_requests([@submitter])
end
@@ -20,7 +20,7 @@ module Api
Templates::CloneAttachments.call(template: cloned_template, original_template: @template)
SendTemplateCreatedWebhookRequestJob.perform_later(cloned_template)
SendTemplateCreatedWebhookRequestJob.perform_later('template_id' => cloned_template.id)
render json: Templates::SerializeForApi.call(cloned_template)
end
+1 -1
View File
@@ -65,7 +65,7 @@ module Api
@template.update!(template_params)
SendTemplateUpdatedWebhookRequestJob.perform_later(@template)
SendTemplateUpdatedWebhookRequestJob.perform_later('template_id' => @template.id)
render json: @template.as_json(only: %i[id updated_at])
end
+3 -1
View File
@@ -36,7 +36,9 @@ class StartFormController < ApplicationController
is_new_record = @submitter.new_record?
if @submitter.save
SendSubmissionCreatedWebhookRequestJob.perform_later(@submitter.submission) if is_new_record
if is_new_record
SendSubmissionCreatedWebhookRequestJob.perform_later({ 'submission_id' => @submitter.submission.id })
end
redirect_to submit_form_path(@submitter.slug)
else
+2 -2
View File
@@ -45,7 +45,7 @@ class SubmissionsController < ApplicationController
end
submissions.each do |submission|
SendSubmissionCreatedWebhookRequestJob.perform_later(submission)
SendSubmissionCreatedWebhookRequestJob.perform_later({ 'submission_id' => submission.id })
end
Submissions.send_signature_requests(submissions)
@@ -56,7 +56,7 @@ class SubmissionsController < ApplicationController
def destroy
@submission.update!(archived_at: Time.current)
SendSubmissionArchivedWebhookRequestJob.perform_later(@submission)
SendSubmissionArchivedWebhookRequestJob.perform_later('submission_id' => @submission.id)
redirect_back(fallback_location: template_path(@submission.template), notice: 'Submission has been archived')
end
+2 -2
View File
@@ -61,7 +61,7 @@ class TemplatesController < ApplicationController
if @template.save
Templates::CloneAttachments.call(template: @template, original_template: @base_template) if @base_template
SendTemplateUpdatedWebhookRequestJob.perform_later(@template)
SendTemplateUpdatedWebhookRequestJob.perform_later('template_id' => @template.id)
maybe_redirect_to_template(@template)
else
@@ -72,7 +72,7 @@ class TemplatesController < ApplicationController
def update
@template.update!(template_params)
SendTemplateUpdatedWebhookRequestJob.perform_later(@template)
SendTemplateUpdatedWebhookRequestJob.perform_later('template_id' => @template.id)
head :ok
end
@@ -18,7 +18,7 @@ class TemplatesUploadsController < ApplicationController
@template.update!(schema:)
SendTemplateCreatedWebhookRequestJob.perform_later(@template)
SendTemplateCreatedWebhookRequestJob.perform_later('template_id' => @template.id)
redirect_to edit_template_path(@template)
rescue Templates::CreateAttachments::PdfEncrypted
@@ -17,7 +17,7 @@ class WebhookSettingsController < ApplicationController
def update
submitter = current_account.submitters.where.not(completed_at: nil).order(:id).last
SendFormCompletedWebhookRequestJob.perform_later(submitter)
SendFormCompletedWebhookRequestJob.perform_later({ 'submitter_id' => submitter.id })
redirect_back(fallback_location: settings_webhooks_path, notice: 'Webhook request has been sent.')
end