Merge branch 'todo-fixes' into 'develop'

Clean up Elixir 1.13 TODOs

See merge request pleroma/pleroma!4233
This commit is contained in:
feld 2024-08-29 15:27:53 +00:00
commit 62856ab18f
3 changed files with 2 additions and 16 deletions

View file

View file

@ -20,15 +20,13 @@ defmodule Pleroma.Maps do
end end
def filter_empty_values(data) do def filter_empty_values(data) do
# TODO: Change to Map.filter in Elixir 1.13+
data data
|> Enum.filter(fn |> Map.filter(fn
{_k, nil} -> false {_k, nil} -> false
{_k, ""} -> false {_k, ""} -> false
{_k, []} -> false {_k, []} -> false
{_k, %{} = v} -> Map.keys(v) != [] {_k, %{} = v} -> Map.keys(v) != []
{_k, _v} -> true {_k, _v} -> true
end) end)
|> Map.new()
end end
end end

View file

@ -803,19 +803,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do
defp build_application(_), do: nil defp build_application(_), do: nil
# Workaround for Elixir issue #10771 @spec build_image_url(URI.t(), URI.t()) :: String.t()
# Avoid applying URI.merge unless necessary
# TODO: revert to always attempting URI.merge(image_url_data, page_url_data)
# when Elixir 1.12 is the minimum supported version
@spec build_image_url(struct() | nil, struct()) :: String.t() | nil
defp build_image_url(
%URI{scheme: image_scheme, host: image_host} = image_url_data,
%URI{} = _page_url_data
)
when not is_nil(image_scheme) and not is_nil(image_host) do
image_url_data |> to_string
end
defp build_image_url(%URI{} = image_url_data, %URI{} = page_url_data) do defp build_image_url(%URI{} = image_url_data, %URI{} = page_url_data) do
URI.merge(page_url_data, image_url_data) |> to_string URI.merge(page_url_data, image_url_data) |> to_string
end end