X-Git-Url: https://git.squeep.com/?a=blobdiff_plain;ds=sidebyside;f=lib%2Fpleroma%2Finstances.ex;h=6b57e56da03175130778c0c1d2b0b85332a9cf8a;hb=e8806fdc42b2b097cc69600a0535d92e1e469d4f;hp=c9b1ed4ce22fdd26caed2522b2acbf995ecd4b8c;hpb=6a679d80c9030afa8327377928f8ac2fcf1a4a0e;p=akkoma
diff --git a/lib/pleroma/instances.ex b/lib/pleroma/instances.ex
index c9b1ed4ce..6b57e56da 100644
--- a/lib/pleroma/instances.ex
+++ b/lib/pleroma/instances.ex
@@ -1,16 +1,22 @@
# Pleroma: A lightweight social networking server
-# Copyright © 2017-2020 Pleroma Authors
+# Copyright © 2017-2021 Pleroma Authors
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Instances do
@moduledoc "Instances context."
- @adapter Pleroma.Instances.Instance
+ alias Pleroma.Instances.Instance
- defdelegate filter_reachable(urls_or_hosts), to: @adapter
- 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
+ def filter_reachable(urls_or_hosts), do: Instance.filter_reachable(urls_or_hosts)
+
+ def reachable?(url_or_host), do: Instance.reachable?(url_or_host)
+
+ def set_reachable(url_or_host), do: Instance.set_reachable(url_or_host)
+
+ def set_unreachable(url_or_host, unreachable_since \\ nil),
+ do: Instance.set_unreachable(url_or_host, unreachable_since)
+
+ def get_consistently_unreachable, do: Instance.get_consistently_unreachable()
def set_consistently_unreachable(url_or_host),
do: set_unreachable(url_or_host, reachability_datetime_threshold())
@@ -37,32 +43,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