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)
This commit is contained in:
parent
47ba796f41
commit
173f69c854
3 changed files with 16 additions and 9 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue