@impl Provider
def build_tags(%{activity: activity, user: user}) do
- with truncated_content = scrub_html_and_truncate(activity.data["object"]["content"]) do
+ with truncated_content = scrub_html_and_truncate(activity) do
attachments = build_attachments(activity)
[
end)
end
+ defp scrub_html_and_truncate(%{data: %{ "object" => %{ "content" => content}}} = activity) do
+ content
+ # html content comes from DB already encoded, decode first and scrub after
+ |> HtmlEntities.decode()
+ |> String.replace(~r/<br\s?\/?>/, " ")
+ |> HTML.get_cached_stripped_html_for_object(activity, __MODULE__)
+ |> Formatter.truncate()
+ end
+
defp scrub_html_and_truncate(content) do
content
# html content comes from DB already encoded, decode first and scrub after
|> HTML.strip_tags()
|> Formatter.truncate()
end
-
defp attachment_url(url) do
MediaProxy.url(url)
end