expire download links

This commit is contained in:
Pete Matsyburka
2025-08-31 16:40:18 +03:00
parent 02c7cdcd97
commit c4a693846e
26 changed files with 184 additions and 78 deletions
+4 -3
View File
@@ -14,7 +14,8 @@ module Templates
module_function
def call(template, schema_documents = template.schema_documents.preload(:blob), preview_image_attachments = nil)
def call(template, schema_documents: template.schema_documents.preload(:blob), preview_image_attachments: nil,
expires_at: Accounts.link_expires_at(Account.new(id: template.account_id)))
json = template.as_json(SERIALIZE_PARAMS)
preview_image_attachments ||=
@@ -40,8 +41,8 @@ module Templates
{
'id' => attachment.id,
'uuid' => attachment.uuid,
'url' => ActiveStorage::Blob.proxy_url(attachment.blob),
'preview_image_url' => first_page_blob && ActiveStorage::Blob.proxy_url(first_page_blob),
'url' => ActiveStorage::Blob.proxy_url(attachment.blob, expires_at:),
'preview_image_url' => first_page_blob && ActiveStorage::Blob.proxy_url(first_page_blob, expires_at:),
'filename' => attachment.filename
}
end