2
0

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
parent d1fb957361
commit 24d943fee0
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