uploads: refactor to simplify ugoira-handling and replacements:
* Make it so replacing a post doesn't generate a dummy upload as a side effect. * Make it so you can't replace a post with itself (the post should be regenerated instead). * Refactor uploads and replacements to save the ugoira frame data when the MediaAsset is created, not when the post is created. This way it's possible to view the ugoira before the post is created. * Make `download_file!` in the Pixiv source strategy return a MediaFile with the ugoira frame data already attached to it, instead of returning it in the `data` field then passing it around separately in the `context` field of the upload.
This commit is contained in:
@@ -276,10 +276,6 @@ module Sources
|
||||
image_url
|
||||
end
|
||||
|
||||
def data
|
||||
{}
|
||||
end
|
||||
|
||||
def tags
|
||||
(@tags || []).uniq
|
||||
end
|
||||
|
||||
@@ -199,6 +199,12 @@ module Sources
|
||||
tag.gsub(/\d+users入り\z/i, "")
|
||||
end
|
||||
|
||||
def download_file!(url = image_url)
|
||||
file = super(url)
|
||||
file.frame_data = ugoira_frame_data if is_ugoira?
|
||||
file
|
||||
end
|
||||
|
||||
def translate_tag(tag)
|
||||
translated_tags = super(tag)
|
||||
|
||||
@@ -297,8 +303,9 @@ module Sources
|
||||
end
|
||||
end
|
||||
|
||||
def data
|
||||
{ ugoira_frame_data: api_ugoira[:frames] }
|
||||
def ugoira_frame_data
|
||||
return nil unless is_ugoira?
|
||||
api_ugoira[:frames]
|
||||
end
|
||||
|
||||
def ugoira_content_type
|
||||
|
||||
Reference in New Issue
Block a user