+
+ def render_content(%{"type" => object_type} = object)
+ when object_type in ["Article", "Page"] do
+ with summary when not is_nil(summary) and summary != "" <- object["name"],
+ url when is_bitstring(url) <- object["url"] do
+ "<p><a href=\"#{url}\">#{summary}</a></p>#{object["content"]}"
+ else
+ _ -> object["content"] || ""
+ end
+ end
+
+ def render_content(object), do: object["content"] || ""
+
+ @doc """
+ Builds a dictionary tags.
+
+ ## Examples
+
+ iex> Pleroma.Web.MastodonAPI.StatusView.build_tags(["fediverse", "nextcloud"])
+ [{"name": "fediverse", "url": "/tag/fediverse"},
+ {"name": "nextcloud", "url": "/tag/nextcloud"}]
+
+ """
+ @spec build_tags(list(any())) :: list(map())
+ def build_tags(object_tags) when is_list(object_tags) do
+ object_tags = for tag when is_binary(tag) <- object_tags, do: tag
+
+ Enum.reduce(object_tags, [], fn tag, tags ->
+ tags ++ [%{name: tag, url: "/tag/#{tag}"}]
+ end)
+ end
+
+ def build_tags(_), do: []
+
+ @doc """
+ Builds list emojis.
+
+ Arguments: `nil` or list tuple of name and url.
+
+ Returns list emojis.
+
+ ## Examples
+
+ iex> Pleroma.Web.MastodonAPI.StatusView.build_emojis([{"2hu", "corndog.png"}])
+ [%{shortcode: "2hu", static_url: "corndog.png", url: "corndog.png", visible_in_picker: false}]
+
+ """
+ @spec build_emojis(nil | list(tuple())) :: list(map())
+ def build_emojis(nil), do: []
+
+ def build_emojis(emojis) do
+ emojis
+ |> Enum.map(fn {name, url} ->
+ name = HTML.strip_tags(name)
+
+ url =
+ url
+ |> HTML.strip_tags()
+ |> MediaProxy.url()
+
+ %{shortcode: name, url: url, static_url: url, visible_in_picker: false}
+ end)
+ end
+
+ defp present?(nil), do: false
+ defp present?(false), do: false
+ defp present?(_), do: true