mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 22:43:33 +08:00
REFACTOR: Refactor pull_hotlinked_images job
This commit should cause no functional change - Split into functions to avoid deep nesting - Register custom field type, and remove manual json parse/serialize - Recover from deleted upload records Also adds a test to ensure pull_hotlinked_images redownloads secure images only once
This commit is contained in:
@ -178,21 +178,11 @@ class CookedPostProcessor
|
||||
end
|
||||
|
||||
def large_images
|
||||
@large_images ||=
|
||||
begin
|
||||
JSON.parse(@post.custom_fields[Post::LARGE_IMAGES].presence || "[]")
|
||||
rescue JSON::ParserError
|
||||
[]
|
||||
end
|
||||
@large_images ||= @post.custom_fields[Post::LARGE_IMAGES].presence || []
|
||||
end
|
||||
|
||||
def broken_images
|
||||
@broken_images ||=
|
||||
begin
|
||||
JSON.parse(@post.custom_fields[Post::BROKEN_IMAGES].presence || "[]")
|
||||
rescue JSON::ParserError
|
||||
[]
|
||||
end
|
||||
@broken_images ||= @post.custom_fields[Post::BROKEN_IMAGES].presence || []
|
||||
end
|
||||
|
||||
def downloaded_images
|
||||
|
Reference in New Issue
Block a user