diff options
author | Sergey Suprunenko <suprunenko.s@gmail.com> | 2019-04-02 11:25:51 +0200 |
---|---|---|
committer | Sergey Suprunenko <suprunenko.s@gmail.com> | 2019-04-02 11:32:36 +0200 |
commit | 3db923515057b7da23e4bb58a1696cd14df7ed52 (patch) | |
tree | 3e1315c6028d3f47db103fd7aaa5d542a870f329 /lib | |
parent | b6f9f7b8aa659c10049b8c43326e58a4b1b18664 (diff) | |
download | pleroma-3db923515057b7da23e4bb58a1696cd14df7ed52.tar.gz |
Ignore dates in wrong formats
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pleroma/web/common_api/utils.ex | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/lib/pleroma/web/common_api/utils.ex b/lib/pleroma/web/common_api/utils.ex index 3f5348d66..0bf4de2f6 100644 --- a/lib/pleroma/web/common_api/utils.ex +++ b/lib/pleroma/web/common_api/utils.ex @@ -15,6 +15,8 @@ defmodule Pleroma.Web.CommonAPI.Utils do alias Pleroma.Web.Endpoint alias Pleroma.Web.MediaProxy + require Logger + # This is a hack for twidere. def get_by_id_or_ap_id(id) do activity = @@ -240,28 +242,19 @@ defmodule Pleroma.Web.CommonAPI.Utils do Strftime.strftime!(date, "%a %b %d %H:%M:%S %z %Y") end - def date_to_asctime(date) when is_float(date) do - date - |> trunc() - |> date_to_asctime() - end - - def date_to_asctime(date) when is_integer(date) do - with {:ok, date} <- DateTime.from_unix(date) do + def date_to_asctime(date) when is_binary(date) do + with {:ok, date, _offset} <- DateTime.from_iso8601(date) do format_asctime(date) else _e -> + Logger.warn("Date #{date} in wrong format, must be ISO 8601") "" end end def date_to_asctime(date) do - with {:ok, date, _offset} <- DateTime.from_iso8601(date) do - format_asctime(date) - else - _e -> - "" - end + Logger.warn("Date #{date} in wrong format, must be ISO 8601") + "" end def to_masto_date(%NaiveDateTime{} = date) do |