FIX: Do not attempt to pull_hotlinked_image for raw_html

raw_html posts (i.e. those which are pulled as part of our comments integration) don't go through our markdown pipeline, so `upload://` URLs are not supported. Running pull_hotlinked_images will break any images in the post.

In future we may add support for pulling hotlinked images in these posts. But for now, disabling it will stop it breaking images.
This commit is contained in:
David Taylor 2022-04-04 20:14:48 +01:00 committed by Alan Guo Xiang Tan
parent b982992ef7
commit 39ac476db6
2 changed files with 13 additions and 0 deletions

View File

@ -16,6 +16,7 @@ module Jobs
post = Post.find_by(id: @post_id)
return if post.blank?
return if post.topic.blank?
return if post.cook_method == Post.cook_methods[:raw_html]
raw = post.raw.dup
start_raw = raw.dup

View File

@ -197,6 +197,18 @@ describe Jobs::PullHotlinkedImages do
expect(post.uploads).to contain_exactly(upload)
end
it "skips raw_html posts" do
raw = "<img src=\"#{image_url}\">"
post = Fabricate(:post, raw: raw, cook_method: Post.cook_methods[:raw_html])
stub_image_size
expect do
post.rebake!
post.reload
end.not_to change { Upload.count }
expect(post.raw).to eq(raw)
end
context "when secure media enabled for an upload that has already been downloaded and exists" do
it "doesnt redownload the secure upload" do
setup_s3