Change media attachments in moderated posts to not be accessible (#34872)

This commit is contained in:
Eugen Rochko 2025-06-12 10:53:02 +02:00 committed by GitHub
commit 24d943fee0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 140 additions and 111 deletions

View file

@ -20,6 +20,21 @@ module RoutingHelper
URI.join(asset_host, source).to_s
end
def expiring_asset_url(attachment, expires_in)
case Paperclip::Attachment.default_options[:storage]
when :s3, :azure
attachment.expiring_url(expires_in.to_i)
when :fog
if Paperclip::Attachment.default_options.dig(:fog_credentials, :openstack_temp_url_key).present?
attachment.expiring_url(expires_in.from_now)
else
full_asset_url(attachment.url)
end
when :filesystem
full_asset_url(attachment.url)
end
end
def asset_host
Rails.configuration.action_controller.asset_host || root_url
end