Merge branch 'cycles-html' into 'develop'

Recompilation speedup: Break out activity-specific HTML functions into Pleroma.Activity.HTML

See merge request pleroma/pleroma!3426
This commit is contained in:
feld 2021-05-29 21:19:25 +00:00
commit b5f3a5c979
4 changed files with 49 additions and 38 deletions

View file

@ -260,7 +260,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do
content_html =
content
|> HTML.get_cached_scrubbed_html_for_activity(
|> Activity.HTML.get_cached_scrubbed_html_for_activity(
User.html_filter_policy(opts[:for]),
activity,
"mastoapi:content"
@ -268,7 +268,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do
content_plaintext =
content
|> HTML.get_cached_stripped_html_for_activity(
|> Activity.HTML.get_cached_stripped_html_for_activity(
activity,
"mastoapi:content"
)

View file

@ -3,6 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.Metadata.Utils do
alias Pleroma.Activity
alias Pleroma.Emoji
alias Pleroma.Formatter
alias Pleroma.HTML
@ -13,7 +14,7 @@ defmodule Pleroma.Web.Metadata.Utils do
# 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_activity(object, "metadata")
|> Activity.HTML.get_cached_stripped_html_for_activity(object, "metadata")
|> Emoji.Formatter.demojify()
|> HtmlEntities.decode()
|> Formatter.truncate()