X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=lib%2Fpleroma%2Fweb%2Factivity_pub%2Fmrf%2Fmedia_proxy_warming_policy.ex;h=0fb05d3c4be9dafa2cee8427b0922b55e6dcc48d;hb=04b514c567aa664d2606313d17be69e665a7f1af;hp=d9a0acfd3959f399d269e36dc28f626115ed2ac3;hpb=e8493431bfc16977e43715bf8bdb09ac46580028;p=akkoma diff --git a/lib/pleroma/web/activity_pub/mrf/media_proxy_warming_policy.ex b/lib/pleroma/web/activity_pub/mrf/media_proxy_warming_policy.ex index d9a0acfd3..0fb05d3c4 100644 --- a/lib/pleroma/web/activity_pub/mrf/media_proxy_warming_policy.ex +++ b/lib/pleroma/web/activity_pub/mrf/media_proxy_warming_policy.ex @@ -12,17 +12,21 @@ defmodule Pleroma.Web.ActivityPub.MRF.MediaProxyWarmingPolicy do require Logger - @hackney_options [ + @adapter_options [ pool: :media, recv_timeout: 10_000 ] def perform(:prefetch, url) do - Logger.debug("Prefetching #{inspect(url)}") + # Fetching only proxiable resources + if MediaProxy.enabled?() and MediaProxy.url_proxiable?(url) do + # If preview proxy is enabled, it'll also hit media proxy (so we're caching both requests) + prefetch_url = MediaProxy.preview_url(url) - url - |> MediaProxy.url() - |> HTTP.get([], adapter: @hackney_options) + Logger.debug("Prefetching #{inspect(url)} as #{inspect(prefetch_url)}") + + HTTP.get(prefetch_url, [], @adapter_options) + end end def perform(:preload, %{"object" => %{"attachment" => attachments}} = _message) do