Fix multiple-choice poll detection

This commit is contained in:
Haelwenn (lanodan) Monnier 2020-06-15 00:30:45 +02:00
commit 4644a8bd10
No known key found for this signature in database
GPG key ID: D5B7A8E43C997DEE
3 changed files with 19 additions and 11 deletions

View file

@ -340,8 +340,13 @@ defmodule Pleroma.Web.CommonAPI do
end
end
defp get_options_and_max_count(%{data: %{"anyOf" => any_of}}), do: {any_of, Enum.count(any_of)}
defp get_options_and_max_count(%{data: %{"oneOf" => one_of}}), do: {one_of, 1}
defp get_options_and_max_count(%{data: %{"anyOf" => any_of}})
when is_list(any_of) and any_of != [],
do: {any_of, Enum.count(any_of)}
defp get_options_and_max_count(%{data: %{"oneOf" => one_of}})
when is_list(one_of) and one_of != [],
do: {one_of, 1}
defp normalize_and_validate_choices(choices, object) do
choices = Enum.map(choices, fn i -> if is_binary(i), do: String.to_integer(i), else: i end)