1 defmodule Pleroma.Instances do
2 @moduledoc "Instances context."
4 @adapter Pleroma.Instances.Instance
6 defdelegate filter_reachable(urls), to: @adapter
7 defdelegate reachable?(url), to: @adapter
8 defdelegate set_reachable(url), to: @adapter
9 defdelegate set_unreachable(url, unreachable_since \\ nil), to: @adapter
11 def reachability_datetime_threshold do
12 federation_reachability_timeout_days =
13 Pleroma.Config.get(:instance)[:federation_reachability_timeout_days] || 90
15 if federation_reachability_timeout_days > 0 do
17 NaiveDateTime.utc_now(),
18 -federation_reachability_timeout_days * 24 * 3600,
22 ~N[0000-01-01 00:00:00]
26 def host(url_or_host) when is_binary(url_or_host) do
27 if url_or_host =~ ~r/^http/i do
28 URI.parse(url_or_host).host