Merge branch 'features/poll-validation' into 'develop'
Poll and votes pipeline ingestion Closes #1362 and #1852 See merge request pleroma/pleroma!2635
This commit is contained in:
commit
34cbe9f44a
29 changed files with 1033 additions and 207 deletions
|
|
@ -28,10 +28,10 @@ defmodule Pleroma.Web.MastodonAPI.PollView do
|
|||
|
||||
def render("show.json", %{object: object} = params) do
|
||||
case object.data do
|
||||
%{"anyOf" => options} when is_list(options) ->
|
||||
%{"anyOf" => [_ | _] = options} ->
|
||||
render(__MODULE__, "show.json", Map.merge(params, %{multiple: true, options: options}))
|
||||
|
||||
%{"oneOf" => options} when is_list(options) ->
|
||||
%{"oneOf" => [_ | _] = options} ->
|
||||
render(__MODULE__, "show.json", Map.merge(params, %{multiple: false, options: options}))
|
||||
|
||||
_ ->
|
||||
|
|
@ -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