diff --git a/app/controllers/account/exports_controller.rb b/app/controllers/account/exports_controller.rb index 13d000002..ab40286af 100644 --- a/app/controllers/account/exports_controller.rb +++ b/app/controllers/account/exports_controller.rb @@ -9,7 +9,6 @@ class Account::ExportsController < ApplicationController def create Current.account.exports.create!(user: Current.user).build_later - redirect_to account_settings_path, notice: "Export started. You'll receive an email when it's ready." end diff --git a/app/models/account/export.rb b/app/models/account/export.rb index 65e033690..3f1832b3a 100644 --- a/app/models/account/export.rb +++ b/app/models/account/export.rb @@ -19,15 +19,11 @@ class Account::Export < ApplicationRecord def build processing! - zipfile = generate_zip - file.attach( - io: File.open(zipfile.path), - filename: "fizzy-export-#{id}.zip", - content_type: "application/zip" - ) + file.attach io: File.open(zipfile.path), filename: "fizzy-export-#{id}.zip", content_type: "application/zip" mark_completed + ExportMailer.completed(self).deliver_later rescue => e update!(status: :failed) diff --git a/app/models/card/exportable.rb b/app/models/card/exportable.rb index b1edfc1fa..ffff82581 100644 --- a/app/models/card/exportable.rb +++ b/app/models/card/exportable.rb @@ -34,24 +34,26 @@ module Card::Exportable return "" if rich_text.blank? rich_text.body.render_attachments do |attachment| - attachable = attachment.attachable - - case attachable - when ActiveStorage::Blob - path = export_attachment_path(attachable) - if attachable.image? - tag.img(src: path, alt: attachable.filename) - else - tag.a(attachable.filename, href: path) - end - when ActionText::Attachables::RemoteImage - tag.img(src: attachable.url, alt: "Remote image") - else - attachment.to_html - end + attachment_representation(attachment) end.to_html end + def attachment_representation(attachment) + case attachable = attachment.attachable + when ActiveStorage::Blob + path = export_attachment_path(attachable) + if attachable.image? + tag.img(src: path, alt: attachable.filename) + else + tag.a(attachable.filename, href: path) + end + when ActionText::Attachables::RemoteImage + tag.img(src: attachable.url, alt: "Remote image") + else + attachment.to_html + end + end + def export_user(user) { id: user.id,