X-Git-Url: https://git.squeep.com/?a=blobdiff_plain;f=lib%2Fpleroma%2Finstances%2Finstance.ex;h=2e1696fe217a1a401d3c649071fed8328df184ad;hb=1403798820da21660fb8787ffaf9f54817597636;hp=df471a39d9a501a15050b94bd891e015add8ccce;hpb=78cea44553c936813ffc2c4c47984a64255096ef;p=akkoma diff --git a/lib/pleroma/instances/instance.ex b/lib/pleroma/instances/instance.ex index df471a39d..2e1696fe2 100644 --- a/lib/pleroma/instances/instance.ex +++ b/lib/pleroma/instances/instance.ex @@ -77,7 +77,7 @@ defmodule Pleroma.Instances.Instance do ) end - def reachable?(_), do: true + def reachable?(url_or_host) when is_binary(url_or_host), do: true def set_reachable(url_or_host) when is_binary(url_or_host) do with host <- host(url_or_host), @@ -166,7 +166,8 @@ defmodule Pleroma.Instances.Instance do defp scrape_favicon(%URI{} = instance_uri) do try do - with {:ok, %Tesla.Env{body: html}} <- + with {_, true} <- {:reachable, reachable?(instance_uri.host)}, + {:ok, %Tesla.Env{body: html}} <- Pleroma.HTTP.get(to_string(instance_uri), [{"accept", "text/html"}], pool: :media), {_, [favicon_rel | _]} when is_binary(favicon_rel) <- {:parse, @@ -175,7 +176,15 @@ defmodule Pleroma.Instances.Instance do {:merge, URI.merge(instance_uri, favicon_rel) |> to_string()} do favicon else - _ -> nil + {:reachable, false} -> + Logger.debug( + "Instance.scrape_favicon(\"#{to_string(instance_uri)}\") ignored unreachable host" + ) + + nil + + _ -> + nil end rescue e ->