mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2024-11-04 23:53:11 +00:00
5bb88fd174
Related to #85 Everything should now be configured at runtime, with the exception of the `Pleroma.HTML` scrubbers (the scrubbers used can be changed at runtime, but their configuration is compile-time) because it's building a module with a macro.
24 lines
556 B
Elixir
24 lines
556 B
Elixir
defmodule Pleroma.Web.ActivityPub.MRF.NormalizeMarkup do
|
|
alias Pleroma.HTML
|
|
|
|
@behaviour Pleroma.Web.ActivityPub.MRF
|
|
|
|
def filter(%{"type" => activity_type} = object) when activity_type == "Create" do
|
|
scrub_policy = Pleroma.Config.get([:mrf_normalize_markup, :scrub_policy])
|
|
|
|
child = object["object"]
|
|
|
|
content =
|
|
child["content"]
|
|
|> HTML.filter_tags(scrub_policy)
|
|
|
|
child = Map.put(child, "content", content)
|
|
|
|
object = Map.put(object, "object", child)
|
|
|
|
{:ok, object}
|
|
end
|
|
|
|
def filter(object), do: {:ok, object}
|
|
end
|