Verified Commit b2da5262 authored by Haelwenn's avatar Haelwenn
Browse files

Pleroma.Web.ActivityPub.Transmogrifier: fix_url when not a string/empty

Thanks prismo.news, I hate it
parent 755f1664
Pipeline #4226 passed with stages
in 5 minutes and 43 seconds
......@@ -57,6 +57,7 @@ def fix_object(object) do
object
|> fix_actor
|> fix_attachments
|> fix_url
|> fix_context
|> fix_in_reply_to
|> fix_emoji
......@@ -171,6 +172,27 @@ def fix_attachments(%{"attachment" => attachment} = object) when is_map(attachme
def fix_attachments(object), do: object
def fix_url(%{"url" => url} = object) when is_map(url) do
object
|> Map.put("url", url["href"])
end
def fix_url(%{"url" => url} = object) when is_list(url) do
first_element = Enum.at(url, 0)
url_string =
cond do
is_bitstring(first_element) -> first_element
is_map(first_element) -> first_element["href"] || ""
true -> ""
end
object
|> Map.put("url", url_string)
end
def fix_url(object), do: object
def fix_emoji(%{"tag" => tags} = object) when is_list(tags) do
emoji = tags |> Enum.filter(fn data -> data["type"] == "Emoji" and data["icon"] end)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment