Skip to content
Snippets Groups Projects
Unverified Commit e4a627f5 authored by Sébastien Gaya's avatar Sébastien Gaya
Browse files

async attachments

parent 519e2649
No related branches found
No related tags found
No related merge requests found
......@@ -49,6 +49,7 @@ class Communication::Website::Imported::Page < ApplicationRecord
optional: true
before_validation :sync
after_save :sync_attachments
default_scope { order(:path) }
......@@ -92,8 +93,11 @@ class Communication::Website::Imported::Page < ApplicationRecord
page.text = Wordpress.clean_html content.to_s
page.published = true
page.save
end
def sync_attachments
if featured_medium.present?
unless featured_medium.file.attached?
unless featured_medium.file.attached? && featured_medium.file.blob.persisted?
featured_medium.load_remote_file!
featured_medium.save
end
......@@ -118,4 +122,5 @@ class Communication::Website::Imported::Page < ApplicationRecord
end
page.update(text: rich_text_with_attachments(page.text.to_s))
end
handle_asynchronously :sync_attachments, queue: 'default'
end
......@@ -48,6 +48,7 @@ class Communication::Website::Imported::Post < ApplicationRecord
optional: true
before_validation :sync
after_save :sync_attachments
default_scope { order(path: :desc) }
......@@ -94,8 +95,11 @@ class Communication::Website::Imported::Post < ApplicationRecord
post.published_at = published_at if published_at
post.published = true
post.save
end
def sync_attachments
if featured_medium.present?
unless featured_medium.file.attached?
unless featured_medium.file.attached? && featured_medium.file.blob.persisted?
featured_medium.load_remote_file!
featured_medium.save
end
......@@ -120,4 +124,5 @@ class Communication::Website::Imported::Post < ApplicationRecord
end
post.update(text: rich_text_with_attachments(post.text.to_s))
end
handle_asynchronously :sync_attachments, queue: 'default'
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment