process acro form fields

This commit is contained in:
Alex Turchyn
2024-06-22 13:16:22 +03:00
committed by Pete Matsyburka
parent 320fe02e35
commit 749043dfbb
10 changed files with 374 additions and 17 deletions
@@ -12,11 +12,14 @@ class TemplatesUploadsController < ApplicationController
save_template!(@template, url_params)
documents = Templates::CreateAttachments.call(@template, url_params || params)
documents = Templates::CreateAttachments.call(@template, url_params || params, extract_fields: true)
schema = documents.map { |doc| { attachment_uuid: doc.uuid, name: doc.filename.base } }
@template.update!(schema:)
fields = Templates::ProcessDocument.normalize_attachment_fields(@template, documents)
schema.each { |item| item['pending_fields'] = true } if fields.present?
@template.update!(schema:, fields:)
SendTemplateCreatedWebhookRequestJob.perform_async('template_id' => @template.id)