diff options
author | lambda <lain@soykaf.club> | 2019-04-02 14:18:23 +0000 |
---|---|---|
committer | lambda <lain@soykaf.club> | 2019-04-02 14:18:23 +0000 |
commit | 256b492a5855c09f45af0325a9e9cd2508c88366 (patch) | |
tree | f88f28e5fbc2c85dfd106ec9dceb1394588db1a0 /lib | |
parent | a79ce94dd4f0b6435ec2aaba5d8867984b491664 (diff) | |
parent | 3db923515057b7da23e4bb58a1696cd14df7ed52 (diff) | |
download | pleroma-256b492a5855c09f45af0325a9e9cd2508c88366.tar.gz |
Merge branch 'bugfix/wrong-date-format' into 'develop'
Support activities with dates in the Unix timestamp format
Closes #763
See merge request pleroma/pleroma!1004
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pleroma/web/common_api/utils.ex | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/pleroma/web/common_api/utils.ex b/lib/pleroma/web/common_api/utils.ex index 40cea3090..9cd8b3758 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,15 +242,21 @@ defmodule Pleroma.Web.CommonAPI.Utils do Strftime.strftime!(date, "%a %b %d %H:%M:%S %z %Y") end - def date_to_asctime(date) do - with {:ok, date, _offset} <- date |> DateTime.from_iso8601() 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 + Logger.warn("Date #{date} in wrong format, must be ISO 8601") + "" + end + def to_masto_date(%NaiveDateTime{} = date) do date |> NaiveDateTime.to_iso8601() |