From b2d9948c30016a28cd2a4286a3c1c116c7f0194c Mon Sep 17 00:00:00 2001 From: Pete Matsyburka Date: Sat, 30 May 2026 22:37:39 +0300 Subject: [PATCH] remove active storage analyzers --- app/controllers/api/attachments_controller.rb | 6 +++--- app/views/profile/index.html.erb | 4 ++-- app/views/submissions/show.html.erb | 6 ++++-- config/application.rb | 2 ++ lib/submitters.rb | 5 +++-- lib/submitters/generate_font_image.rb | 4 +++- lib/submitters/normalize_values.rb | 6 ++++-- 7 files changed, 21 insertions(+), 12 deletions(-) diff --git a/app/controllers/api/attachments_controller.rb b/app/controllers/api/attachments_controller.rb index 1d24f8ca..2bb0db92 100644 --- a/app/controllers/api/attachments_controller.rb +++ b/app/controllers/api/attachments_controller.rb @@ -11,8 +11,6 @@ module Api @submitter = Submitter.find_by!(slug: params[:submitter_slug]) unless can_upload?(@submitter) - Rollbar.error("Can't upload: #{@submitter.id}") if defined?(Rollbar) - return render json: { error: I18n.t('form_has_been_archived') }, status: :unprocessable_content end @@ -33,9 +31,11 @@ module Api return render json: { error: "#{params[:type]} error, try to sign on another device" }, status: :unprocessable_content end + + metadata = { analyzed: true, identified: true, width: image.width, height: image.height } end - attachment = Submitters.create_attachment!(@submitter, file) + attachment = Submitters.create_attachment!(@submitter, file, metadata:) if params[:remember_signature] == 'true' && @submitter.email.present? cookies.encrypted[:signature_uuids] = build_new_cookie_signatures_json(@submitter, attachment) diff --git a/app/views/profile/index.html.erb b/app/views/profile/index.html.erb index c2211349..016f29ef 100644 --- a/app/views/profile/index.html.erb +++ b/app/views/profile/index.html.erb @@ -36,7 +36,7 @@ <% if signature %>
<%= button_to button_title(title: t('remove'), disabled_with: t('removing')), user_signature_path, method: :delete, class: 'right-0 top-0 absolute link' %> - +
<% end %> @@ -49,7 +49,7 @@ <% if initials %>
<%= button_to button_title(title: t('remove'), disabled_with: t('removing')), user_initials_path, method: :delete, class: 'right-0 top-0 absolute link' %> - +
<% end %>
diff --git a/app/views/submissions/show.html.erb b/app/views/submissions/show.html.erb index 7922949c..3d23b90a 100644 --- a/app/views/submissions/show.html.erb +++ b/app/views/submissions/show.html.erb @@ -266,10 +266,12 @@
<% if field['type'].in?(%w[signature initials]) %>
- <%= field['name'] || field['title'] || field['type'] %> + <% img_height = attachments_index[value].metadata['height'] %> + <%= field['name'] || field['title'] || field['type'] %>
<% elsif field['type'].in?(['image', 'stamp', 'kba']) && attachments_index[value].image? %> - <%= field['name'] || field['title'] || field['type'] %> + <% img_height = attachments_index[value].metadata['height'] %> + <%= field['name'] || field['title'] || field['type'] %> <% elsif field['type'].in?(['file', 'payment', 'image']) %>
<% Array.wrap(value).each do |val| %> diff --git a/config/application.rb b/config/application.rb index b9131dc3..a44c39b0 100644 --- a/config/application.rb +++ b/config/application.rb @@ -25,6 +25,8 @@ module DocuSeal config.active_storage.draw_routes = ENV['MULTITENANT'] != 'true' + config.active_storage.analyzers = [] + config.active_storage.content_types_to_serve_as_binary += %w[ application/javascript text/javascript diff --git a/lib/submitters.rb b/lib/submitters.rb index cdb4ee43..97041550 100644 --- a/lib/submitters.rb +++ b/lib/submitters.rb @@ -122,7 +122,7 @@ module Submitters end end - def create_attachment!(submitter, file) + def create_attachment!(submitter, file, metadata: {}) raise ParamsError, 'file param is missing' if file.blank? extension = File.extname(file.original_filename).delete_prefix('.').downcase @@ -133,7 +133,8 @@ module Submitters blob = ActiveStorage::Blob.create_and_upload!(io: file.tap(&:rewind).open, filename: file.original_filename, - content_type: file.content_type) + content_type: file.content_type, + metadata:) ActiveStorage::Attachment.create!(blob:, name: 'attachments', record: submitter) end diff --git a/lib/submitters/generate_font_image.rb b/lib/submitters/generate_font_image.rb index b70d7450..0413355f 100644 --- a/lib/submitters/generate_font_image.rb +++ b/lib/submitters/generate_font_image.rb @@ -27,7 +27,9 @@ module Submitters text_mask = Vips::Image.black(text_image.width, text_image.height) - text_mask.bandjoin(text_image).copy(interpretation: :b_w).write_to_buffer('.png') + image = text_mask.bandjoin(text_image).copy(interpretation: :b_w) + + [image.write_to_buffer('.png'), image.width, image.height] end end end diff --git a/lib/submitters/normalize_values.rb b/lib/submitters/normalize_values.rb index fe9f2d02..54149f72 100644 --- a/lib/submitters/normalize_values.rb +++ b/lib/submitters/normalize_values.rb @@ -260,7 +260,7 @@ module Submitters end def find_or_create_blob_from_text(account, text, type) - data = Submitters::GenerateFontImage.call(text, font: type) + data, width, height = Submitters::GenerateFontImage.call(text, font: type) checksum = Digest::MD5.base64digest(data) @@ -268,7 +268,9 @@ module Submitters blob || ActiveStorage::Blob.create_and_upload!( io: StringIO.new(data), - filename: "#{type}.png" + filename: "#{type}.png", + content_type: 'image/png', + metadata: { analyzed: true, identified: true, width:, height: } ) end