diff options
author | Haelwenn (lanodan) Monnier <contact@hacktivis.me> | 2020-06-15 05:18:30 +0200 |
---|---|---|
committer | Haelwenn (lanodan) Monnier <contact@hacktivis.me> | 2020-07-15 11:39:56 +0200 |
commit | 173f69c854adf966d52b3767c4de43a0b1ce5b00 (patch) | |
tree | 249201952994273a16a100544d44fc7f98f39fdb /lib/pleroma/web/mastodon_api | |
parent | 47ba796f415740c443cd8477c121280656b13032 (diff) | |
download | pleroma-173f69c854adf966d52b3767c4de43a0b1ce5b00.tar.gz |
question_validator: fix for mastodon poll expiration
Mastodon activities do not have a "closed" field, this could be seen on
https://pouet.it/users/lanodan_tmp/statuses/104345126997708380
which runs Mastodon 3.1.4 (SDF runs 3.1.2)
Diffstat (limited to 'lib/pleroma/web/mastodon_api')
-rw-r--r-- | lib/pleroma/web/mastodon_api/views/poll_view.ex | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/lib/pleroma/web/mastodon_api/views/poll_view.ex b/lib/pleroma/web/mastodon_api/views/poll_view.ex index 73c990e2e..ce595ae8a 100644 --- a/lib/pleroma/web/mastodon_api/views/poll_view.ex +++ b/lib/pleroma/web/mastodon_api/views/poll_view.ex @@ -40,15 +40,13 @@ defmodule Pleroma.Web.MastodonAPI.PollView do end defp end_time_and_expired(object) do - case object.data["closed"] || object.data["endTime"] do - end_time when is_binary(end_time) -> - end_time = NaiveDateTime.from_iso8601!(end_time) - expired = NaiveDateTime.compare(end_time, NaiveDateTime.utc_now()) == :lt + if object.data["closed"] do + end_time = NaiveDateTime.from_iso8601!(object.data["closed"]) + expired = NaiveDateTime.compare(end_time, NaiveDateTime.utc_now()) == :lt - {Utils.to_masto_date(end_time), expired} - - _ -> - {nil, false} + {Utils.to_masto_date(end_time), expired} + else + {nil, false} end end |