remove active storage analyzers
This commit is contained in:
@@ -11,8 +11,6 @@ module Api
|
|||||||
@submitter = Submitter.find_by!(slug: params[:submitter_slug])
|
@submitter = Submitter.find_by!(slug: params[:submitter_slug])
|
||||||
|
|
||||||
unless can_upload?(@submitter)
|
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
|
return render json: { error: I18n.t('form_has_been_archived') }, status: :unprocessable_content
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -33,9 +31,11 @@ module Api
|
|||||||
return render json: { error: "#{params[:type]} error, try to sign on another device" },
|
return render json: { error: "#{params[:type]} error, try to sign on another device" },
|
||||||
status: :unprocessable_content
|
status: :unprocessable_content
|
||||||
end
|
end
|
||||||
|
|
||||||
|
metadata = { analyzed: true, identified: true, width: image.width, height: image.height }
|
||||||
end
|
end
|
||||||
|
|
||||||
attachment = Submitters.create_attachment!(@submitter, file)
|
attachment = Submitters.create_attachment!(@submitter, file, metadata:)
|
||||||
|
|
||||||
if params[:remember_signature] == 'true' && @submitter.email.present?
|
if params[:remember_signature] == 'true' && @submitter.email.present?
|
||||||
cookies.encrypted[:signature_uuids] = build_new_cookie_signatures_json(@submitter, attachment)
|
cookies.encrypted[:signature_uuids] = build_new_cookie_signatures_json(@submitter, attachment)
|
||||||
|
|||||||
@@ -36,7 +36,7 @@
|
|||||||
<% if signature %>
|
<% if signature %>
|
||||||
<div class="flex justify-center mb-4 relative">
|
<div class="flex justify-center mb-4 relative">
|
||||||
<%= button_to button_title(title: t('remove'), disabled_with: t('removing')), user_signature_path, method: :delete, class: 'right-0 top-0 absolute link' %>
|
<%= button_to button_title(title: t('remove'), disabled_with: t('removing')), user_signature_path, method: :delete, class: 'right-0 top-0 absolute link' %>
|
||||||
<img src="<%= signature.url %>" style="max-height: 200px; object-fit: contain;" width="<%= signature.metadata['width'] %>" height="<%= signature.metadata['height'] %>">
|
<img src="<%= signature.url %>" style="height: 130px; width: 100%; object-fit: contain;">
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
<a href="<%= edit_user_signature_path %>" data-turbo-frame="modal" class="base-button w-full">
|
<a href="<%= edit_user_signature_path %>" data-turbo-frame="modal" class="base-button w-full">
|
||||||
@@ -49,7 +49,7 @@
|
|||||||
<% if initials %>
|
<% if initials %>
|
||||||
<div class="flex justify-center mb-4 relative">
|
<div class="flex justify-center mb-4 relative">
|
||||||
<%= button_to button_title(title: t('remove'), disabled_with: t('removing')), user_initials_path, method: :delete, class: 'right-0 top-0 absolute link' %>
|
<%= button_to button_title(title: t('remove'), disabled_with: t('removing')), user_initials_path, method: :delete, class: 'right-0 top-0 absolute link' %>
|
||||||
<img src="<%= initials.url %>" style="max-height: 200px; object-fit: contain;" width="<%= initials.metadata['width'] %>" height="<%= initials.metadata['height'] %>">
|
<img src="<%= initials.url %>" style="height: 130px; width: 100%; object-fit: contain;">
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
<a href="<%= edit_user_initials_path %>" data-turbo-frame="modal" class="base-button w-full">
|
<a href="<%= edit_user_initials_path %>" data-turbo-frame="modal" class="base-button w-full">
|
||||||
|
|||||||
@@ -266,10 +266,12 @@
|
|||||||
<div dir="auto">
|
<div dir="auto">
|
||||||
<% if field['type'].in?(%w[signature initials]) %>
|
<% if field['type'].in?(%w[signature initials]) %>
|
||||||
<div class="w-full bg-base-300 py-1">
|
<div class="w-full bg-base-300 py-1">
|
||||||
<img class="object-contain mx-auto" style="max-height: <%= field['type'] == 'signature' ? 100 : 50 %>px" height="<%= attachments_index[value].metadata['height'] %>" width="<%= attachments_index[value].metadata['width'] %>" src="<%= attachments_index[value].url %>" loading="lazy" alt="<%= field['name'] || field['title'] || field['type'] %>">
|
<% img_height = attachments_index[value].metadata['height'] %>
|
||||||
|
<img class="object-contain mx-auto" style="<%= 'max-' if img_height %>height: <%= field['type'] == 'signature' ? 100 : 50 %>px" height="<%= img_height %>" width="<%= attachments_index[value].metadata['width'] %>" src="<%= attachments_index[value].url %>" loading="lazy" alt="<%= field['name'] || field['title'] || field['type'] %>">
|
||||||
</div>
|
</div>
|
||||||
<% elsif field['type'].in?(['image', 'stamp', 'kba']) && attachments_index[value].image? %>
|
<% elsif field['type'].in?(['image', 'stamp', 'kba']) && attachments_index[value].image? %>
|
||||||
<img class="object-contain mx-auto max-h-28" style="max-height: 200px" height="<%= attachments_index[value].metadata['height'] %>" width="<%= attachments_index[value].metadata['width'] %>" src="<%= attachments_index[value].url %>" loading="lazy" alt="<%= field['name'] || field['title'] || field['type'] %>">
|
<% img_height = attachments_index[value].metadata['height'] %>
|
||||||
|
<img class="object-contain mx-auto" style="<%= 'max-' if img_height %>height: 200px" height="<%= img_height %>" width="<%= attachments_index[value].metadata['width'] %>" src="<%= attachments_index[value].url %>" loading="lazy" alt="<%= field['name'] || field['title'] || field['type'] %>">
|
||||||
<% elsif field['type'].in?(['file', 'payment', 'image']) %>
|
<% elsif field['type'].in?(['file', 'payment', 'image']) %>
|
||||||
<div class="flex flex-col justify-center">
|
<div class="flex flex-col justify-center">
|
||||||
<% Array.wrap(value).each do |val| %>
|
<% Array.wrap(value).each do |val| %>
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ module DocuSeal
|
|||||||
|
|
||||||
config.active_storage.draw_routes = ENV['MULTITENANT'] != 'true'
|
config.active_storage.draw_routes = ENV['MULTITENANT'] != 'true'
|
||||||
|
|
||||||
|
config.active_storage.analyzers = []
|
||||||
|
|
||||||
config.active_storage.content_types_to_serve_as_binary += %w[
|
config.active_storage.content_types_to_serve_as_binary += %w[
|
||||||
application/javascript
|
application/javascript
|
||||||
text/javascript
|
text/javascript
|
||||||
|
|||||||
+3
-2
@@ -122,7 +122,7 @@ module Submitters
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_attachment!(submitter, file)
|
def create_attachment!(submitter, file, metadata: {})
|
||||||
raise ParamsError, 'file param is missing' if file.blank?
|
raise ParamsError, 'file param is missing' if file.blank?
|
||||||
|
|
||||||
extension = File.extname(file.original_filename).delete_prefix('.').downcase
|
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,
|
blob = ActiveStorage::Blob.create_and_upload!(io: file.tap(&:rewind).open,
|
||||||
filename: file.original_filename,
|
filename: file.original_filename,
|
||||||
content_type: file.content_type)
|
content_type: file.content_type,
|
||||||
|
metadata:)
|
||||||
|
|
||||||
ActiveStorage::Attachment.create!(blob:, name: 'attachments', record: submitter)
|
ActiveStorage::Attachment.create!(blob:, name: 'attachments', record: submitter)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -27,7 +27,9 @@ module Submitters
|
|||||||
|
|
||||||
text_mask = Vips::Image.black(text_image.width, text_image.height)
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -260,7 +260,7 @@ module Submitters
|
|||||||
end
|
end
|
||||||
|
|
||||||
def find_or_create_blob_from_text(account, text, type)
|
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)
|
checksum = Digest::MD5.base64digest(data)
|
||||||
|
|
||||||
@@ -268,7 +268,9 @@ module Submitters
|
|||||||
|
|
||||||
blob || ActiveStorage::Blob.create_and_upload!(
|
blob || ActiveStorage::Blob.create_and_upload!(
|
||||||
io: StringIO.new(data),
|
io: StringIO.new(data),
|
||||||
filename: "#{type}.png"
|
filename: "#{type}.png",
|
||||||
|
content_type: 'image/png',
|
||||||
|
metadata: { analyzed: true, identified: true, width:, height: }
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user