Merge branch 'bugfix/prismo.news_article_url' into 'develop'

Bugfix/prismo.news article url

Closes #352

See merge request pleroma/pleroma!410
This commit is contained in:
Haelwenn 2018-11-01 09:05:16 +00:00
commit 40676d7683
2 changed files with 23 additions and 1 deletions

View file

@ -57,6 +57,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
object
|> fix_actor
|> fix_attachments
|> fix_url
|> fix_context
|> fix_in_reply_to
|> fix_emoji
@ -171,6 +172,27 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
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)

View file

@ -240,7 +240,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do
summary = object["name"]
content =
if !!summary and summary != "" do
if !!summary and summary != "" and is_bitstring(object["url"]) do
"<p><a href=\"#{object["url"]}\">#{summary}</a></p>#{object["content"]}"
else
object["content"]