[#1149] Fixed failing tests. Ensured Instance.set_unreachable/2 supports ISO 8601 datetime.
This commit is contained in:
parent
267262491e
commit
33a5fc4a70
6 changed files with 20 additions and 6 deletions
|
|
@ -90,7 +90,7 @@ defmodule Pleroma.Instances.Instance do
|
|||
def set_unreachable(url_or_host, unreachable_since \\ nil)
|
||||
|
||||
def set_unreachable(url_or_host, unreachable_since) when is_binary(url_or_host) do
|
||||
unreachable_since = unreachable_since || DateTime.utc_now()
|
||||
unreachable_since = parse_datetime(unreachable_since) || NaiveDateTime.utc_now()
|
||||
host = host(url_or_host)
|
||||
existing_record = Repo.get_by(Instance, %{host: host})
|
||||
|
||||
|
|
@ -114,4 +114,10 @@ defmodule Pleroma.Instances.Instance do
|
|||
end
|
||||
|
||||
def set_unreachable(_, _), do: {:error, nil}
|
||||
|
||||
defp parse_datetime(datetime) when is_binary(datetime) do
|
||||
NaiveDateTime.from_iso8601(datetime)
|
||||
end
|
||||
|
||||
defp parse_datetime(datetime), do: datetime
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue