Revert "FIX: Do not attempt to pull_hotlinked on emoji images when CDN enabled"

This changed cause plugin spec failures and needs further investigation

This reverts commit 78626d2832.
This commit is contained in:
David Taylor 2020-06-19 14:39:16 +01:00
parent 29dc2058c5
commit a99bb0ded4
No known key found for this signature in database
GPG Key ID: 46904C18B1D3F434
2 changed files with 6 additions and 18 deletions

View File

@ -173,7 +173,7 @@ module Jobs
# If file is on the forum or CDN domain or already has the
# secure media url
if UrlHelper.is_local(src) || Upload.secure_media_url?(src)
if Discourse.store.has_been_uploaded?(src) || src =~ /\A\/[^\/]/i || Upload.secure_media_url?(src)
return false if src =~ /\/images\/emoji\//
# Someone could hotlink a file from a different site on the same CDN,

View File

@ -360,23 +360,6 @@ describe Jobs::PullHotlinkedImages do
end
end
it "returns false for emoji" do
src = Emoji.url_for("testemoji.png")
expect(subject.should_download_image?(src)).to eq(false)
end
it "returns false for emoji when app and S3 CDNs configured" do
set_cdn_url "https://mydomain.cdn/test"
SiteSetting.s3_upload_bucket = "some-bucket-on-s3"
SiteSetting.s3_access_key_id = "s3-access-key-id"
SiteSetting.s3_secret_access_key = "s3-secret-access-key"
SiteSetting.s3_cdn_url = "https://s3.cdn.com"
SiteSetting.enable_s3_uploads = true
src = UrlHelper.cook_url(Emoji.url_for("testemoji.png"))
expect(subject.should_download_image?(src)).to eq(false)
end
context "when download_remote_images_to_local? is false" do
before do
SiteSetting.download_remote_images_to_local = false
@ -387,6 +370,11 @@ describe Jobs::PullHotlinkedImages do
expect(subject.should_download_image?(src)).to eq(true)
end
it "returns false for emoji" do
src = Emoji.url_for("testemoji.png")
expect(subject.should_download_image?(src)).to eq(false)
end
it 'returns false for valid remote URLs' do
expect(subject.should_download_image?("http://meta.discourse.org")).to eq(false)
end