Merge branch 'systemd-drop-sysadmin-privilege' into 'develop'
[akkoma] / lib / pleroma / web / activity_pub / mrf / normalize_markup.ex
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2018 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.Web.ActivityPub.MRF.NormalizeMarkup do
6 alias Pleroma.HTML
7
8 @behaviour Pleroma.Web.ActivityPub.MRF
9
10 def filter(%{"type" => activity_type} = object) when activity_type == "Create" do
11 scrub_policy = Pleroma.Config.get([:mrf_normalize_markup, :scrub_policy])
12
13 child = object["object"]
14
15 content =
16 child["content"]
17 |> HTML.filter_tags(scrub_policy)
18
19 child = Map.put(child, "content", content)
20
21 object = Map.put(object, "object", child)
22
23 {:ok, object}
24 end
25
26 def filter(object), do: {:ok, object}
27 end