Break out activity-specific HTML functions into Pleroma.Activity.HTML

Fixes cycles in lib/pleroma/ecto_type/activity_pub/object_validators/safe_text.ex
This commit is contained in:
Alex Gleason 2021-05-22 16:44:51 -05:00
commit 3ff9c5e2a6
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7
4 changed files with 49 additions and 38 deletions

View file

@ -254,7 +254,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"
@ -262,7 +262,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()