projects
/
akkoma
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
user: Add support for custom emojis in profile fields
[akkoma]
/
lib
/
pleroma
/
instances
/
instance.ex
diff --git
a/lib/pleroma/instances/instance.ex
b/lib/pleroma/instances/instance.ex
index e92006151b218dd3333e50c88ce6ffa6a7d9631a..74458c09aa5043ed0e491fb51eb64101f106c95f 100644
(file)
--- a/
lib/pleroma/instances/instance.ex
+++ b/
lib/pleroma/instances/instance.ex
@@
-1,3
+1,7
@@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
defmodule Pleroma.Instances.Instance do
@moduledoc "Instance."
defmodule Pleroma.Instances.Instance do
@moduledoc "Instance."
@@
-12,7
+16,7
@@
defmodule Pleroma.Instances.Instance do
schema "instances" do
field(:host, :string)
schema "instances" do
field(:host, :string)
- field(:unreachable_since, :naive_datetime)
+ field(:unreachable_since, :naive_datetime
_usec
)
timestamps()
end
timestamps()
end
@@
-86,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
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) || Naive
DateTime.utc_now()
host = host(url_or_host)
existing_record = Repo.get_by(Instance, %{host: host})
host = host(url_or_host)
existing_record = Repo.get_by(Instance, %{host: host})
@@
-110,4
+114,10
@@
defmodule Pleroma.Instances.Instance do
end
def set_unreachable(_, _), do: {:error, nil}
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
end