diff --git a/app/jobs/regular/pull_hotlinked_images.rb b/app/jobs/regular/pull_hotlinked_images.rb index de8bc07cbae..a42d45c08a1 100644 --- a/app/jobs/regular/pull_hotlinked_images.rb +++ b/app/jobs/regular/pull_hotlinked_images.rb @@ -71,6 +71,7 @@ module Jobs filename = File.basename(URI.parse(src).path) filename << File.extname(hotlinked.path) unless filename["."] upload = UploadCreator.new(hotlinked, filename, origin: src).create_for(post.user_id) + if upload.persisted? downloaded_urls[src] = upload.url downloaded_images[remove_scheme(src)] = upload.id @@ -148,7 +149,7 @@ module Jobs def extract_images_from(html) doc = Nokogiri::HTML::fragment(html) - doc.css("img[src], a.lightbox[href], a.onebox[href]") - + doc.css("img[src], a.lightbox[href]") - doc.css("img.avatar") - doc.css(".lightbox img[src]") end diff --git a/spec/jobs/pull_hotlinked_images_spec.rb b/spec/jobs/pull_hotlinked_images_spec.rb index 25b086f4196..17a11889b44 100644 --- a/spec/jobs/pull_hotlinked_images_spec.rb +++ b/spec/jobs/pull_hotlinked_images_spec.rb @@ -98,23 +98,6 @@ describe Jobs::PullHotlinkedImages do expect(post.uploads).to contain_exactly(upload) end - it 'replaces direct links' do - post = Fabricate(:post, raw: <<~MD) - #{image_url} - #{image_url} - MD - - expect { Jobs::PullHotlinkedImages.new.execute(post_id: post.id) } - .to change { Upload.count }.by(1) - - post.reload - - expect(post.raw).to eq(<<~MD.chomp) - ![](#{Upload.last.short_url}) - ![](#{Upload.last.short_url}) - MD - end - it 'replaces markdown image' do post = Fabricate(:post, raw: <<~MD) [![some test](#{image_url})](https://somelink.com)