Merge branch 'deprecate-public_endpoint' into 'develop'
[akkoma] / lib / pleroma / instances.ex
index c9b1ed4ce22fdd26caed2522b2acbf995ecd4b8c..80addcc52d99d2b89388ca4966009284e060b476 100644 (file)
@@ -1,5 +1,5 @@
 # Pleroma: A lightweight social networking server
-# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
+# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
 # SPDX-License-Identifier: AGPL-3.0-only
 
 defmodule Pleroma.Instances do
@@ -11,6 +11,7 @@ defmodule Pleroma.Instances do
   defdelegate reachable?(url_or_host), to: @adapter
   defdelegate set_reachable(url_or_host), to: @adapter
   defdelegate set_unreachable(url_or_host, unreachable_since \\ nil), to: @adapter
+  defdelegate get_consistently_unreachable(), to: @adapter
 
   def set_consistently_unreachable(url_or_host),
     do: set_unreachable(url_or_host, reachability_datetime_threshold())
@@ -37,32 +38,4 @@ defmodule Pleroma.Instances do
       url_or_host
     end
   end
-
-  def get_cached_favicon(instance_url) when is_binary(instance_url) do
-    Cachex.fetch!(:instances_cache, instance_url, fn _ -> get_favicon(instance_url) end)
-  end
-
-  def get_cached_favicon(_instance_url) do
-    nil
-  end
-
-  def get_favicon(instance_url) when is_binary(instance_url) do
-    try do
-      with {:ok, %Tesla.Env{body: html}} <-
-             Pleroma.HTTP.get(instance_url, [{:Accept, "text/html"}]),
-           favicon_rel <-
-             html
-             |> Floki.parse_document!()
-             |> Floki.attribute("link[rel=icon]", "href")
-             |> List.first(),
-           favicon_url <- URI.merge(URI.parse(instance_url), favicon_rel) |> to_string(),
-           true <- is_binary(favicon_url) do
-        favicon_url
-      else
-        _ -> nil
-      end
-    rescue
-      _ -> nil
-    end
-  end
 end