projects
/
akkoma
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
[#1149] Added more oban workers. Refactoring.
[akkoma]
/
lib
/
pleroma
/
instances
/
instance.ex
diff --git
a/lib/pleroma/instances/instance.ex
b/lib/pleroma/instances/instance.ex
index 48bc939dd0958aa5748d46cb09a7d5403a18c87e..544c4b687c8d5e0a9c13a3247fa8e731609b0188 100644
(file)
--- a/
lib/pleroma/instances/instance.ex
+++ b/
lib/pleroma/instances/instance.ex
@@
-1,9
+1,13
@@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
defmodule Pleroma.Instances.Instance do
@moduledoc "Instance."
alias Pleroma.Instances
defmodule Pleroma.Instances.Instance do
@moduledoc "Instance."
alias Pleroma.Instances
- alias Pleroma.Repo
alias Pleroma.Instances.Instance
alias Pleroma.Instances.Instance
+ alias Pleroma.Repo
use Ecto.Schema
use Ecto.Schema
@@
-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