discourse/app/jobs/regular/update_private_uploads_acl.rb
Martin Brennan 02cb01406e
FIX: Allow secure uploads if global s3 setting active and enable_s3_uploads validations (#8373)
The secure media functionality relied on `SiteSetting.enable_s3_uploads?` which, as we found in dev, did not take into account global S3 settings via `GlobalSetting.use_s3?`. We now use `SiteSetting.Upload.enable_s3_uploads` instead to be more consistent.

Also, we now validate `enable_s3_uploads` changes, because if `GlobalSetting.use_s3?` is true users should NOT be enabling S3 uploads manually.
2019-11-20 07:46:44 +10:00

18 lines
431 B
Ruby

# frozen_string_literal: true
module Jobs
class UpdatePrivateUploadsAcl < ::Jobs::Base
# only runs when SiteSetting.prevent_anons_from_downloading_files is updated
def execute(args)
return if !SiteSetting.Upload.enable_s3_uploads
Upload.find_each do |upload|
if !FileHelper.is_supported_media?(upload.original_filename)
upload.update_secure_status
end
end
end
end
end